fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void combination(vector<int> comb, deque<int> numbers) {
  5.  
  6. if (numbers.empty()) {
  7. for (unsigned int i = 0; i < comb.size(); i++) {
  8. cout << comb[i] << " ";
  9. }
  10. cout << "\n";
  11. return;
  12. }
  13.  
  14. comb.push_back(numbers.front());
  15. numbers.pop_front();
  16. combination(comb, numbers);
  17. comb.pop_back();
  18. combination(comb, numbers);
  19. }
  20.  
  21. int main() {
  22. // your code goes here
  23. vector<int> comb;
  24. deque<int> numbers;
  25. for(int i = 0;i < 7;i++) numbers.push_back(i);
  26. combination(comb, numbers);
  27. return 0;
  28. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 
0 1 2 3 4 5 
0 1 2 3 4 6 
0 1 2 3 4 
0 1 2 3 5 6 
0 1 2 3 5 
0 1 2 3 6 
0 1 2 3 
0 1 2 4 5 6 
0 1 2 4 5 
0 1 2 4 6 
0 1 2 4 
0 1 2 5 6 
0 1 2 5 
0 1 2 6 
0 1 2 
0 1 3 4 5 6 
0 1 3 4 5 
0 1 3 4 6 
0 1 3 4 
0 1 3 5 6 
0 1 3 5 
0 1 3 6 
0 1 3 
0 1 4 5 6 
0 1 4 5 
0 1 4 6 
0 1 4 
0 1 5 6 
0 1 5 
0 1 6 
0 1 
0 2 3 4 5 6 
0 2 3 4 5 
0 2 3 4 6 
0 2 3 4 
0 2 3 5 6 
0 2 3 5 
0 2 3 6 
0 2 3 
0 2 4 5 6 
0 2 4 5 
0 2 4 6 
0 2 4 
0 2 5 6 
0 2 5 
0 2 6 
0 2 
0 3 4 5 6 
0 3 4 5 
0 3 4 6 
0 3 4 
0 3 5 6 
0 3 5 
0 3 6 
0 3 
0 4 5 6 
0 4 5 
0 4 6 
0 4 
0 5 6 
0 5 
0 6 
0 
1 2 3 4 5 6 
1 2 3 4 5 
1 2 3 4 6 
1 2 3 4 
1 2 3 5 6 
1 2 3 5 
1 2 3 6 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