Skip to content

Commit f60f985

Browse files
Merge pull request matthewsamuel95#107 from vinodgandas/patch-5
Create subsets_of_set.cpp
2 parents c94b9c0 + 5072f47 commit f60f985

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
void possibleSubsets(char A[], int N)
5+
{
6+
for(int i = 0;i < (1 << N); ++i)
7+
{
8+
for(int j = 0;j < N;++j)
9+
if(i & (1 << j))
10+
cout << A[j] << ‘ ‘;
11+
cout << endl;
12+
}
13+
}
14+
15+
int main()
16+
{
17+
int i, n;
18+
cin >>n;
19+
char a[n];
20+
for(i=0;i<n;i++) cin <<a[i];
21+
possibleSubsets(a, n);
22+
return 0;
23+
}

0 commit comments

Comments
 (0)