• Source
    1. #include<bits/stdc++.h>
    2.  
    3. using namespace std ;
    4.  
    5. char s[55];
    6.  
    7. int main()
    8. {
    9. int len;
    10.  
    11. while(gets(s))
    12. {
    13. if(strcmp(s,"#")==0)
    14. break;
    15.  
    16. len = strlen(s);
    17.  
    18. if(next_permutation(s,s+len))
    19. puts(s);
    20. else
    21. puts("No Successor");
    22. }
    23.  
    24. return 0;
    25. }
    26.