链接:http://acm.hit.edu.cn/hoj/problem/view?id=1191
先了解一下next_permutation()的应用吧;
其作用是:改变区间内元素的顺序,产生下一个排列。
C++/STL中定义的next_permutation和prev_permutation函数则是非常灵活且高效的一种方法,它被广泛的应用
于为指定序列生成不同的排列;
++++#include <algorithm>++++
Code :
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { char str[10005];
while(~scanf("%s", str)) {
if(strcmp(str, "#") == 0) break;
int len = strlen(str);
if(next_permutation(str, str+len)) printf("%s\n", str);
else printf("No Successor\n");
}
return 0;
}
快省赛了,,,努力刷题中。。。