Advertisement
juanjo12x

UVA_146_ID_Codes

Aug 6th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <limits.h>
  15. #include <stdlib.h>
  16. #include <cmath>
  17. #define LL unsigned long long
  18. using namespace std;
  19.  
  20. int main() {
  21.     char cad[51];int n;
  22.     bool entro;
  23.     while(gets(cad)){
  24.         if(strcmp(cad,"#")==0){
  25.             break;
  26.         }
  27.         n=strlen(cad);entro=false;
  28.         while(next_permutation(cad,cad+n)){
  29.             entro=true;
  30.             for(int i=0;i<n;i++)printf("%c",cad[i]);
  31.             printf("\n");break;
  32.         }
  33.         if(!entro){
  34.             printf("No Successor\n");
  35.         }
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement