fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n = 3;
  5.  
  6. void f(int i, bool choice[]){
  7. if(i==n+1){
  8. for(int j = 1; j <= n;j++){
  9. if(choice[j])
  10. cout << j << " ";
  11. }
  12. cout << endl;
  13. return ;
  14.  
  15. }
  16.  
  17. choice[i] = false;
  18. f(i+1,choice);
  19.  
  20. choice[i] = true;
  21. f(i+1,choice);
  22.  
  23.  
  24. }
  25.  
  26. int main() {
  27. // your code goes here
  28. bool v[20];
  29. f(1,v);
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5472KB
stdin
Standard input is empty
stdout
3 
2 
2 3 
1 
1 3 
1 2 
1 2 3