irapilguy

Untitled

Jan 10th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define N 20
  4. int mas[N];
  5. int countt = 0;
  6. int function(int i) {
  7.     if (i == 0){ cout << "0";
  8.     return 0;
  9. }
  10.     if (i == 1){
  11.         cout << "1" << " ";
  12.         return 0;
  13.     }
  14.     mas[countt] = i % 2;
  15.     //cout << i << endl;
  16.     countt++;
  17.  
  18.  
  19.         function(i / 2);
  20.         //cout << " == i == " << i << "==";
  21.     for(int j = countt - 1 ; j >= 0 ; j -- )
  22.         cout << mas[j] << " ";
  23.         //function(i);
  24.     return 0;
  25. }
  26. int main() {
  27.     int n;
  28.     cin >> n;
  29.     /*for (int i = 0; i <= 2 * n - 1; i++) {
  30.         while (i % 2 ==  0 ) {
  31.             cout << i % 2 << " ";
  32.             i = i / 2;
  33.         }
  34.         cout << i / 2 << "\n";
  35.     }*/
  36.     /*while (n != 1) {
  37.         cout << n / 2 << " " << n % 2 << "\n";
  38.         n = n / 2;
  39.     }*/
  40.     for (int i = 0; i <= 2 * n - 1; i++) {
  41.         countt = 0;
  42.         function(i);
  43.         cout << "\n";
  44.     }
  45.     return 0;
  46. }
Add Comment
Please, Sign In to add comment