#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000
#define pf printf
#define sf scanf
int main()
{
char s[MAX];
int len;
while(cin >> s)
{
cin.ignore();
if(s[0]=='#') break;
len = strlen(s);
if(next_permutation(s, s+len))
cout << s << endl;
else
cout << "No Successor" << endl;
}
return 0;
}
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000
#define pf printf
#define sf scanf
int main()
{
char s[MAX];
int len;
while(cin >> s)
{
cin.ignore();
if(s[0]=='#') break;
len = strlen(s);
if(next_permutation(s, s+len))
cout << s << endl;
else
cout << "No Successor" << endl;
}
return 0;
}
No comments:
Post a Comment