View Code
view Problem
----------------------------------------------------------------------------
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int main() { char str[200]; int len; while(gets(str)!=NULL) { if(str[0]=='#') break; len=strlen(str); if(next_permutation(str,str+len)==1) printf("%s\n",str); else printf("No Successor\n"); } return 0; }