算法训练 JAM计数法
1 #include<iostream> 2 #include<algorithm> 3 #include<string> 4 using namespace std; 5 int s,t,w;string str; 6 int main(){ 7 cin>>s>>t>>w;cin>>str; 8 int i,j; 9 for(i=0;i<5;i++){ 10 for(j=w-1;j>=0;j--){ 11 if(str[j]>='a'+t-1-(w-(j+1))){ 12 continue; 13 } 14 else{ 15 str[j]=str[j]+1; 16 for(int k=j;k<w-1;k++){ 17 str[k+1]=str[k]+1; 18 } 19 break; 20 } 21 } 22 if(j==-1){ 23 break; 24 } 25 else{ 26 cout<<str<<endl; 27 } 28 } 29 return 0; 30 }优质内容筛选与推荐>>