fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int n, x[100];
  7. bool ok = true;
  8.  
  9. void init(){
  10. cin >> n;
  11. for(int i = 1; i <= n; i++){
  12. x[i] = 0;
  13. }
  14. }
  15.  
  16. void result(){
  17. for(int i = 1; i <= n; i++){
  18. cout << x[i] << ' ';
  19. }
  20. cout << endl;
  21. }
  22.  
  23. void next_bits_string(){
  24. int i = n;
  25. while(i > 0 && x[i] == 1){
  26. x[i] = 0;
  27. i--;
  28. }
  29. if(i == 0){
  30. ok = false;
  31. }
  32. else{
  33. x[i] = 1;
  34. }
  35. }
  36.  
  37. int main(){
  38. init();
  39. while(ok){
  40. result();
  41. next_bits_string();
  42. }
  43. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout