Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define N 20
- int mas[N];
- int countt = 0;
- int function(int i) {
- if (i == 0){ cout << "0";
- return 0;
- }
- if (i == 1){
- cout << "1" << " ";
- return 0;
- }
- mas[countt] = i % 2;
- //cout << i << endl;
- countt++;
- function(i / 2);
- //cout << " == i == " << i << "==";
- for(int j = countt - 1 ; j >= 0 ; j -- )
- cout << mas[j] << " ";
- //function(i);
- return 0;
- }
- int main() {
- int n;
- cin >> n;
- /*for (int i = 0; i <= 2 * n - 1; i++) {
- while (i % 2 == 0 ) {
- cout << i % 2 << " ";
- i = i / 2;
- }
- cout << i / 2 << "\n";
- }*/
- /*while (n != 1) {
- cout << n / 2 << " " << n % 2 << "\n";
- n = n / 2;
- }*/
- for (int i = 0; i <= 2 * n - 1; i++) {
- countt = 0;
- function(i);
- cout << "\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment