Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03
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
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
3 files changed, 95 insertions, 0 deletions
-rw-r--r--Sem. 03/README.md2
-rw-r--r--Sem. 03/drawing_examples.txt35
-rw-r--r--Sem. 03/solutions/exercise 15.cpp58
diff --git a/Sem. 03/README.md b/Sem. 03/README.md
index dae7155..35624d4 100644
--- a/Sem. 03/README.md
+++ b/Sem. 03/README.md
@@ -160,5 +160,7 @@ do
+**Задача 15:** Да се напише програма, която приема цяло положително число n и отпечатва следната папионка:
+![enter image description here](https://i.ibb.co/NKSPm4z/ddz.png)
diff --git a/Sem. 03/drawing_examples.txt b/Sem. 03/drawing_examples.txt
index d8fad73..73e3130 100644
--- a/Sem. 03/drawing_examples.txt
+++ b/Sem. 03/drawing_examples.txt
@@ -120,6 +120,13 @@ $ $ $ $
. . . . .
. . . . . .
+вход: 5
+. . . . . . . . . .
+. . . .
+. . . . . . .
+. . . .
+. . . . . . . . . .
+
@@ -153,3 +160,31 @@ $ $ $ $
1
121
1
+
+задача 15:
+
+вход: 3
+
+1 1
+1 2 2 1
+1 2 3 --- 3 2 1
+1 2 2 1
+1 1
+
+вход: 4
+1 1
+1 2 2 1
+1 2 3 3 2 1
+1 2 3 4 ---- 4 3 2 1
+1 2 3 3 2 1
+1 2 2 1
+1 1
+
+
+вход: 2
+
+1 1
+1 2 –- 2 1
+1 1
+
+
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;
+
+ }
+
+
+}