题目地址:http://codeforces.com/problemset/problem/518/A
思路:类似数字,如果存在解,则a的值加一肯定为一个解,否则a的值加一为b。注意处理进位,最后与b字符串比较即可。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=150;
char st[maxn],en[maxn];
int main()
{
scanf("%s%s",st,en);
int l=strlen(st);
st[l-1]++;
int pos=l-1;
while(st[pos]>'z')
{
st[pos]='a';
st[pos-1]++;
pos--;
}
if(strcmp(st,en)==-1) printf("%s\n",st);
else printf("No such string\n");
return 0;
}