Skip to content

Commit 90cb322

Browse files
authored
Create subset
1 parent a4ebc25 commit 90cb322

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

subset

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int a[26],set[10];
6+
char c[10];
7+
8+
void DFS(int now);
9+
10+
int main(){
11+
char ch;
12+
int num,i,cnt=0;
13+
14+
for(i=0;i<10;i++){
15+
cin>>ch;
16+
num=ch-65;
17+
a[num]++;
18+
}
19+
for(i=0;i<26;i++){
20+
if(a[i]!=0){
21+
c[cnt]=i+65;
22+
set[cnt]=a[i];
23+
cnt++;
24+
}
25+
}
26+
DFS(0);
27+
}
28+
29+
void DFS(int now){
30+
int i,j,k,num;
31+
32+
num=set[now];
33+
for(i=set[now];i>=0;i--){
34+
set[now]=i;
35+
if(now+1==10) {
36+
cout<<"{";
37+
for(j=0;j<10;j++){
38+
for(k=0;k<set[j];k++) cout<<c[j];
39+
}
40+
cout<<"} ";
41+
}
42+
if(now+1<10) DFS(now+1);
43+
set[now]=num;
44+
}
45+
}

0 commit comments

Comments
 (0)