-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path195.cpp
More file actions
42 lines (40 loc) · 661 Bytes
/
195.cpp
File metadata and controls
42 lines (40 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
using namespace std;
bool compare(char a,char b)
{
bool capsA=false,capsB=false;
if(a>='A'&&a<='Z')
capsA=true;
if(b>='A'&&b<='Z')
capsB=true;
if(capsA&&capsB)
return a<=b;
if(!capsA&&!capsB)
return a<=b;
else{
if(!capsA){
a=a-32;
return a<=b;
}
else
{
b=b-32;
return a<=b;
}
}
}
int main()
{
int t;
string s;
scanf("%d",&t);
while(t--)
{
cin>>s;
sort(s.begin(),s.end(),compare);
do{
printf("%s\n",((string)s).c_str());
}while(next_permutation(s.begin(),s.end(),compare));
}
return 0;
}