aboutsummaryrefslogtreecommitdiff
path: root/week11/ex4.cpp
blob: ec05144375dc0561cab921e958fa070f3fff097e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

void printNumbers(int currentBit, char* buf, const int N) {
	if (currentBit == 0) {
		std::cout << buf << std::endl;
		return;
	}
	buf[N - currentBit] = '0';
	printNumbers(currentBit - 1, buf, N);
	buf[N - currentBit] = '1';
	printNumbers(currentBit - 1, buf, N);
}

int main() {
	int N;
	std::cin >> N;

	char* buf = new char[N+1];
	buf[N] = '\0';

	printNumbers(N, buf, N);
	delete[] buf;
}