Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / solutions / exercise 15.cpp
diff options
context:
space:
mode:
Commitbf2b3c1b31b22fc3d035c2e116d0c6a471629ba1 (patch)
Author
 Justsvetoslavov <justsvetoslavov@gmail.com>
2021-11-05 13:36:01 +0200
Committer
 Justsvetoslavov <justsvetoslavov@gmail.com>
2021-11-05 13:36:01 +0200
Files4ad08515fd48bf90d95666c0a7cb5045013882a4 /Sem. 03/solutions/exercise 15.cpp
Introduction_to_programming_FMI-bf2b3c1b31b22fc3d035c2e116d0c6a471629ba1.tar
Introduction_to_programming_FMI-bf2b3c1b31b22fc3d035c2e116d0c6a471629ba1.tar.gz
Introduction_to_programming_FMI-bf2b3c1b31b22fc3d035c2e116d0c6a471629ba1.zip
Parent627534742b0fcc94132d4bb13d6a4cc0b51c3d88 (diff)
Parent2d690dadaf0dc606c59ae688011bac2af48d5d69 (diff)
Merge branch 'main' of https://github.com/Angeld55/Introduction_to_programming_FMI
1 files changed, 58 insertions, 0 deletions
-rw-r--r--Sem. 03/solutions/exercise 15.cpp58
diff --git a/Sem. 03/solutions/exercise 15.cpp b/Sem. 03/solutions/exercise 15.cpp
new file mode 100644
index 0000000..652a201
--- /dev/null
+++ b/Sem. 03/solutions/exercise 15.cpp
@@ -0,0 +1,58 @@
+#include <iostream>
+using namespace std;
+
+int main()
+{
+ int n;
+ cin >> n;
+
+ int spacesCount = 2 * (n - 1) + n + 2 * (n - 1);
+ int toGuess;
+ for (int i = 1; i <= n - 1; i++)
+ {
+ for (int j = 1; j <= i; j++)
+ cout << j << " ";
+
+ for (int j = 0; j < spacesCount; j++)
+ cout << " ";
+
+ for (int j = i; j >= 1; j--)
+ cout << " " << j;
+
+ spacesCount -= 4;
+
+ cout << endl;
+
+ }
+
+ //mid
+ for (int i = 1; i <= n; i++)
+ cout << i << " ";
+ for (int i = 0; i < n; i++)
+ cout << '-';
+ for (int i = n; i >= 1; i--)
+ cout << " " << i;
+ cout << endl;
+
+
+ //down
+ spacesCount += 4;
+ for (int i = n - 1; i >= 0; i--)
+ {
+ for (int j = 1; j <= i; j++)
+ cout << j << " ";
+
+ for (int j = 0; j < spacesCount; j++)
+ cout << " ";
+
+ for (int j = i; j >= 1; j--)
+ cout << " " << j;
+
+ spacesCount += 4;
+
+ cout << endl;
+
+ }
+
+
+}