diff options
feat(Week13): Add solutions to most exercises
1 files changed, 29 insertions, 0 deletions
| -rw-r--r-- | Week13/Exercise05.cpp | 29 |
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 <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; +} |
