ACdream 1056 Vitaly and Strings

来源:互联网 发布:星光大道网络报名 编辑:程序博客网 时间:2024/05/20 05:22

一道水题,不过错了很多次,注意一下思维。

Description

Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.

During the last lesson the teacher has provided two stringss andt to Vitaly. The strings have the same length, they consist of lowercase English letters, strings is lexicographically smaller than stringt. Vitaly wondered if there is such string that is lexicographically larger than strings and at the same is lexicographically smaller than stringt. This string should also consist of lowercase English letters and have the length equal to the lengths of stringss andt.

Let's help Vitaly solve this easy problem!

Input

The first line contains strings (1 ≤ |s| ≤ 100), consisting of lowercase English letters. Here,|s| denotes the length of the string.

The second line contains stringt (|t| = |s|), consisting of lowercase English letters.

It is guaranteed that the lengths of stringss andt are the same and strings is lexicographically less than stringt.

Output

If the string that meets the given requirements doesn't exist, print a single string "No such string" (without the quotes).

If such string exists, print it. If there are multiple valid strings, you may print any of them.

Sample Input

Input
ac
Output
b
Input
aaazzz
Output
kkk
Input
abcdefgabcdefh
Output
No such string

#include <iostream>#include <cstring>#include <cstdio>using namespace std;char s1[110], s2[110];int main(){    int flag = 0;    while(~scanf("%s%s", s1, s2)){        int len = strlen(s1);        for(int i = len-1; i >= 0; --i){            if(s1[i] != 'z'){                s1[i]++; flag = 1;                break;            }            else            s1[i] = 'a';        }        if(strcmp(s1, s2) >= 0 || flag == 0)            printf("No such string\n");        else            printf("%s\n", s1);    }    return 0;}

参考博客:http://www.cnblogs.com/I-love-HLD/p/4299364.html

0 0
原创粉丝点击