Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Solutions Sem. 03 / 09. Lefthand_Triangle.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/09. Lefthand_Triangle.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, 24 insertions, 0 deletions
-rw-r--r--Year 1/Programming introduction/Solutions Sem. 03/09. Lefthand_Triangle.cpp24
diff --git a/Year 1/Programming introduction/Solutions Sem. 03/09. Lefthand_Triangle.cpp b/Year 1/Programming introduction/Solutions Sem. 03/09. Lefthand_Triangle.cpp
new file mode 100644
index 0000000..1aba6c7
--- /dev/null
+++ b/Year 1/Programming introduction/Solutions Sem. 03/09. Lefthand_Triangle.cpp
@@ -0,0 +1,24 @@
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ int n;
+ cin >> n;
+
+ for (int row = -n + 1; row < n; row++)
+ {
+ int absRow = ((row > 0) ? row : -row);
+
+ for (int col = absRow; col > 0; col--)
+ cout << " ";
+
+ int numberOnLine = 0;
+
+ for (int col = n - absRow; col > 0; col--)
+ (numberOnLine *= 10) += col;
+
+ cout << numberOnLine << endl;
+ }
+}