标签:bre problem main using ret ble out turn strlen
除了暴力我真没有想出其他的思路。。。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int b,t,w;
char a[105];
char s_s,s_t;
bool s[105];
bool pd()
{
int tot=0;
for(int i=s_t;i>=s_s;i--)
{
if(s[i])
tot++;
else
break;
}
if(tot==w)
return 1;
return 0;
}
void add()
{
int tot=0;
for(int i=s_t;i>=s_s;i--)
{
if(s[i]==1)
{
s[i]=0;
tot++;
}
else
{
for(int j=i;j>=s_s;j--)
{
if(s[j]==1)
{
tot++;
s[j]=0;
for(int k=j+1;tot;k++,tot--)
{
s[k]=1;
}
return;
}
}
}
}
}
void pr()
{
for(int i=s_s;i<=s_t;i++)
{
if(s[i])
{
cout<<(char)(i);
}
}
cout<<'\n';
}
int main()
{
//freopen("number.in","r",stdin);
//freopen("number.out","w",stdout);
cin>>b>>t>>w;
cin>>a;
s_s=b+'a'-1;
s_t=t+'a'-1;
int lena=strlen(a);
for(int i=0;i<lena;i++)
s[a[i]]=1;
if(pd())
return 0;
for(int i=1;i<=5;i++)
{
add();
pr();
if(pd())
break;
}
return 0;
}
标签:bre problem main using ret ble out turn strlen
原文地址:https://www.cnblogs.com/loney-s/p/11845415.html