Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise05.cpp
blob: 7b409d588de5162fd80019d4e921da8b4c47e482 (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
#include <iostream>

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

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

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

	hill(1, n);

	return 0;
}