We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 519b415 commit a3267c3Copy full SHA for a3267c3
C++/Printing_Subset.cpp
@@ -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
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