题目地址:点击打开链接
直接运用STL的next_permutation算法就OK啦
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s;
while(cin>>s&&s!="#")
{
if(next_permutation(s.begin(),s.end()))
{
cout<<s<<endl;
}
else
{
cout<<"No Successor"<<endl;
}
}
return 0;
}