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