私信TA

用户名:uq_42410893353

访问量:3146

签 名:

菜狗只希望蓝桥杯拿个好成绩,呜呜~

等  级
排  名 4489
经  验 1622
参赛次数 0
文章发表 21
年  龄 0
在职情况 学生
学  校 韩庄乡男子电力职业技术学院
专  业

  自我简介:

从后往前找第一个不是当前位置最大可能值的字母,将这个字母加一,往后依次的值为前一个字母加一。
参考代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<sstream>
#include<cstring>
#include<utility>
using namespace std;
typedef long long ll;
typedef long l;
const int N=1<<10+1;
int s,t,w,cnt=5;char f[30];
int main(){
    scanf("%d%d%d",&s,&t,&w);char c=getchar();
    while(c<'a'||c>'z'){
    	c=getchar();
	}
	f[1]=c;
    for(int i=2;i<=w;i++)scanf("%c",&f[i]);
    while(cnt--){
    	int cnt1=0;
	    for(int i=w,j=t;i>0;i--,j--){
    	    if(f[i]>='a'-1+j){
    	    	//cout<<f[i]<<(char)('a'-1+j);
			    cnt1++;
				continue;
    	    }
    	    else{
			    f[i]++;
    	        //cout<<f[i];
    	        for(int j=i+1;j<=w;j++)f[j]=f[j-1]+1;
    	        break;
    	    }
        }
        if(cnt1==w)break;
        for(int i=1;i<=w;i++)printf("%c",f[i]);
        cout<<endl;
	}
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区