From 5c3b97fb2572ce8940439abd0652d2a7f7a623bd Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 11 Jan 2026 13:43:39 +0200 Subject: feat(Week13): Add solutions to most exercises --- Week13/Exercise05.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Week13/Exercise05.cpp (limited to 'Week13/Exercise05.cpp') diff --git a/Week13/Exercise05.cpp b/Week13/Exercise05.cpp new file mode 100644 index 0000000..7b409d5 --- /dev/null +++ b/Week13/Exercise05.cpp @@ -0,0 +1,29 @@ +#include + +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; +} -- cgit v1.3.1-23-gd82d