Skip to content

Commit a3267c3

Browse files
authored
Create Printing_Subset.cpp
1 parent 519b415 commit a3267c3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

C++/Printing_Subset.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
vector<vector<int>> ss, subarray;
5+
6+
7+
void Index_subset (int num, int size, vector<int> subset) {
8+
if ( num > size ){
9+
ss.push_back(subset);
10+
}
11+
else {
12+
subset.push_back(num);
13+
Index_subset(num+1, size, subset);
14+
subset.pop_back();
15+
Index_subset(num+1, size, subset);
16+
}
17+
}
18+
19+
int main() {
20+
21+
cout<<"Enter any Number x : ";
22+
int n; cin>>n;
23+
24+
vector<int> v,v1(n);
25+
26+
cout<<"\nEnter x numbers : ";
27+
for(int i=0; i<n; i++){cin>>v1[i];}
28+
29+
Index_subset(0,n,v);
30+
printSubArrays(v1,0,0);
31+
32+
cout<<"\n";
33+
34+
for(auto h : ss){
35+
cout<<"[ ";
36+
for(int x : h){
37+
cout<<x<<" ";
38+
}
39+
cout<<"] ";
40+
}
41+
42+
}

0 commit comments

Comments
 (0)