Sunday, April 10, 2016

UVA 146

#include<bits/stdc++.h>

using namespace std;

int main()
{
 char s[100];
 
 while(cin>>s)
 {
  if(s[0] == '#') break;
  long long l=strlen(s);
  
  if(next_permutation(s,s+l))
  {
   cout<<s<<endl;
  }
  else cout<<"No Successor"<<endl;
 }
 
 return 0;
}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)