Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise01.cpp
blob: ed5797ecf8bc4c482ab8d6c9fb2f3c4ee3ecaa8b (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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>

void line(unsigned n) {
	if (n == 0) {
		std::cout << std::endl;
	}
	else {
		std::cout << '+';
		line(n - 1);
	}
}

/* Два начина по които да имплементираме изкарването на "стълбите" */

void stairs1(unsigned i, unsigned max) {
	if (i <= max) {
		line(i);
		stairs1(i + 1, max);
	}
}

void stairs2(unsigned n) {
	if (n > 0) {
		stairs2(n - 1);
		line(n);
	}
}

int main() {
	unsigned n;
	std::cin >> n;

	// stairs1(1, n);
	stairs2(n);

	return 0;
}