fork(4) download
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. void go(vector<int> a, int x)
  6. {
  7. a[x] = x;
  8. for(int i = 1; i <= 5; i++)
  9. cout << a[i] << " ";
  10. cout << endl;
  11. if(x == 3)
  12. return;
  13. go(a, x+1);
  14. for(int i = 1; i <= 5; i++)
  15. cout << a[i] << " ";
  16. cout << endl;
  17. }
  18.  
  19. int main()
  20. {
  21. vector<int> a(100, 0);
  22.  
  23. go(a, 1);
  24. }
Success #stdin #stdout 0s 2860KB
stdin
Standard input is empty
stdout
1 0 0 0 0 
1 2 0 0 0 
1 2 3 0 0 
1 2 0 0 0 
1 0 0 0 0