题目地址:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_problem&problem=1039
题目大意:
同Q146,比146还要简单,按照字典序输出输入序列的所有排列。
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
using namespace std;
#define MAX 10+1
int main()
{
#ifdef Local
freopen("a.in", "r", stdin);
freopen("a.out", "w", stdout);
#endif
char s[MAX];
int t = 0;
cin >> t;
getchar();
while (t--)
{
cin >> s;
int len = strlen(s);
sort(s, s+len);
do
{
cout << s << endl;
}while (next_permutation(s, s+len));
cout << endl;
}
}