Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #include <sstream>
- #include <limits.h>
- #include <stdlib.h>
- #include <cmath>
- #define LL unsigned long long
- using namespace std;
- int main() {
- char cad[51];int n;
- bool entro;
- while(gets(cad)){
- if(strcmp(cad,"#")==0){
- break;
- }
- n=strlen(cad);entro=false;
- while(next_permutation(cad,cad+n)){
- entro=true;
- for(int i=0;i<n;i++)printf("%c",cad[i]);
- printf("\n");break;
- }
- if(!entro){
- printf("No Successor\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement