fork download
  1. #include<iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int n,a[100],ok;
  6. void nhap(){
  7. cin>>n;
  8. for(int i=1;i<=n;i++) a[i]=0;
  9. ok=0;
  10. }
  11. void xuat(){
  12. for(int i=1;i<=n;i++) cout<<a[i];
  13. cout<<'\n';
  14. }
  15. void sinh(){
  16. int d=n;
  17. while(a[d]==1){
  18. a[d]=0;d--;
  19. }
  20. if(d==0){
  21. ok=1;
  22. }else{
  23. a[d]=1;
  24. }
  25. }
  26. void xuli(){
  27. nhap();
  28. while(ok==0){
  29. xuat();
  30. sinh();
  31. }
  32. }
  33. int main(){
  34. xuli();
  35. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
stdout
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111