#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<limits>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define LLU long long unsigned int
#define LLD long long double
#define FOR(i,N) for(int i=0;i<(N);i++)
int main()
{
int N;
scanf(“%d\n”,&N);
string s;
while(N–)
{
getline(cin, s);
vector <char> vec;
int len = s.length();
FOR(i, len)
{
vec.push_back(s[i]);
}
sort(vec.begin(), vec.end());
do
{
FOR(i, len)
{
printf(“%c”,vec[i]);
}
printf(“\n”);
}while(next_permutation(vec.begin(), vec.end()));
printf(“\n”);
}
}
No comments:
Post a Comment