Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Solutions Sem. 03 / 14. Tree.cpp
diff options
context:
space:
mode:
Commita69cd34091836c632c3268e646ac5a85fb9f8175 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-29 10:27:03 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-29 10:27:03 +0300
Files1f28671a0f73a702831bbbb68ccecbc734e79623 /Year 1/Programming introduction/Solutions Sem. 03/14. Tree.cpp
uni-projects-a69cd34091836c632c3268e646ac5a85fb9f8175.tar
uni-projects-a69cd34091836c632c3268e646ac5a85fb9f8175.tar.gz
uni-projects-a69cd34091836c632c3268e646ac5a85fb9f8175.zip
Parent2ec5faa88be1447cd93a301543f97ac9d6c312d7 (diff)
Added my solutions to Sem. 03 exercises
1 files changed, 30 insertions, 0 deletions
-rw-r--r--Year 1/Programming introduction/Solutions Sem. 03/14. Tree.cpp30
diff --git a/Year 1/Programming introduction/Solutions Sem. 03/14. Tree.cpp b/Year 1/Programming introduction/Solutions Sem. 03/14. Tree.cpp
new file mode 100644
index 0000000..1955730
--- /dev/null
+++ b/Year 1/Programming introduction/Solutions Sem. 03/14. Tree.cpp
@@ -0,0 +1,30 @@
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int n;
+ cin >> n;
+
+ // Tree crown
+ for (int row = 1; row <= n; row++)
+ {
+ for (int col = n - row; col > 0; col--)
+ cout << " ";
+
+ for (int col = -row + 1; col < row; col++)
+ cout << row - ((col < 0) ? -col : col);
+
+ cout << endl;
+ }
+
+ // Tree trunk
+ for (int row = n - 1; row > 0; row--)
+ {
+ for (int col = n - 1; col > 0; col--)
+ cout << " ";
+
+ cout << row << endl;
+ }
+}