Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int n, a[100];
- queue<int>q;
- void printqueue(queue<int>q)
- {
- while (!q.empty())
- {
- cout << q.front() << ' ';
- q.pop();
- }
- cout << endl;
- }
- void GenerateSubset(int i)
- {
- if (i == n)
- {
- printqueue(q);
- return;
- }
- GenerateSubset(i + 1);
- q.push(a[i]);
- GenerateSubset(i + 1);
- q.pop();
- }
- main()
- {
- cin >> n;
- for (int i = 0; i < n; i++) cin >> a[i];
- GenerateSubset(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement