直接用STL中的next_permutation即可
代码如下:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <vector>
#define ll long long
using namespace std;
char s[10];
int main()
{
int i, j, k;
scanf("%s", s);
int x = strlen(s);
sort( s, s + x);
do{
puts( s);
}while ( next_permutation( s, s + x));
return 0;
}