全排列,真好用---------729也是
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int n;
char str[1000];
cin>>n;
while(n--)
{
cin>>str;
sort(str,str+strlen(str));
cout<<str<<endl;
while(next_permutation(str,str+strlen(str)))
cout<<str<<endl;
cout<<endl;
}
return 0;
}