next_permutation(,)只能说这个函数尊的很好用,必备
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
char str[100];
while (cin >> str&&str[0]!='#') {
int len = strlen(str);
if (next_permutation(str, str + len))
cout << str << endl;
else
cout <<"No Successor"<< endl;
}
return 0;
}