#include<cstdio> #include<iostream> #include<algorithm> #include<vector> using namespace std; int main() { string s; while(cin >> s) { if(s=="#")break; int i,j,k,l,m,n,f=0; vector<char>v; for(i=0;i<s.length()-1;i++) { if(s[i]<s[i+1]) { f=1; } v.push_back(s[i]); } v.push_back(s[i]); if(f==0) { cout << "No Successor" << endl; } else { next_permutation(v.begin(),v.end()); for(i=0;i<v.size();i++) { printf("%c",v[i]); }printf("\n"); } } return 0; }
No comments:
Post a Comment