fork download
  1. #include<iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int n,x[10];
  6. void in(){
  7. for(int i=1;i<=n;i++) cout<<x[i];
  8. cout<<endl;
  9. }
  10. void xau(int i){
  11. for(int j=0;j<=1;j++){
  12. x[i]=j;
  13. if(i==n) in();
  14. else xau(i+1);
  15. }
  16. }
  17. int main(){
  18. cin>>n;
  19. xau(1);
  20. }
Success #stdin #stdout 0.01s 5444KB
stdin
4
stdout
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111