来源:点击打开链接
求字典序下一位,没有直接输出没有。全排列函数秒水过。
#include <iostream> #include <algorithm> #include <cstring> #include <string> using namespace std; int main() { int testcase; string tar; while(cin>>tar && tar!="#") { if(next_permutation(tar.begin(),tar.end())) { cout<<tar<<endl; } else { cout<<"No Successor"<<endl; } } }