无语啊,直接用stl的next_permutation函数就行了,我还手写。唉,stl一定要掌握好啊!
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std ; int main() { char st[205]; gets(st); int len=strlen(st); sort(st,st+len); puts(st); while(next_permutation(st,st+len)){ puts(st); } return 0 ; }