Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit5fd50da2d856b972b21903c8dfcaa1d2c58c884f (patch)
Author
 Angel Dimitriev <achi_d@abv.bg>
2021-11-08 16:32:31 +0200
Committer
 GitHub <noreply@github.com>
2021-11-08 16:32:31 +0200
Filese7ba7a60fa2347e3c1fa62ec0e3ddd2a0483f433
Introduction_to_programming_FMI-5fd50da2d856b972b21903c8dfcaa1d2c58c884f.tar
Introduction_to_programming_FMI-5fd50da2d856b972b21903c8dfcaa1d2c58c884f.tar.gz
Introduction_to_programming_FMI-5fd50da2d856b972b21903c8dfcaa1d2c58c884f.zip
Parent91819bddb6acf136949263d9013c3c26655c5f43 (diff)
Update task16_sem3.cpp
1 files changed, 42 insertions, 32 deletions
-rw-r--r--Sem. 05/task16_sem3.cpp74
diff --git a/Sem. 05/task16_sem3.cpp b/Sem. 05/task16_sem3.cpp
index 652a201..bed9616 100644
--- a/Sem. 05/task16_sem3.cpp
+++ b/Sem. 05/task16_sem3.cpp
@@ -1,58 +1,68 @@
#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 << " ";
+ //up
+ for (int i = 0; i < n + 2; i++)
+ cout << '#';
+ cout << endl;
- for (int j = i; j >= 1; j--)
- cout << " " << j;
- spacesCount -= 4;
+ for (int i = 0; i < n; i++)
+ {
+ cout << '#';
- cout << endl;
+ for (int j = i + 1; j <= n + i; j++)
+ {
+ if (j > n)
+ cout << j % n;
+ else
+ cout << j;
+ }
+ 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;
+ cout << "#";
- //down
- spacesCount += 4;
- for (int i = n - 1; i >= 0; i--)
+ for (int i = 0; i < n; i++)
{
- for (int j = 1; j <= i; j++)
- cout << j << " ";
+ if (n % 2 == 1 && n / 2 == i)
+ cout << "x";
+ else if (n % 2 == 0 && ((n / 2 == i) || (n / 2 - 1 == i)))
+ cout << "x";
+ else
+ cout << ' ';
+ }
- for (int j = 0; j < spacesCount; j++)
- cout << " ";
+ cout << '#' << endl;
- for (int j = i; j >= 1; j--)
- cout << " " << j;
- spacesCount += 4;
+ //down
+ for (int i = n - 1; i >= 0; i--)
+ {
+ cout << '#';
- cout << endl;
+ for (int j = i + 1; j <= n + i; j++)
+ {
+ if (j > n)
+ cout << j % n;
+ else
+ cout << j;
+ }
+ cout << '#' << endl;
}
+ for (int i = 0; i < n + 2; i++)
+ cout << '#';
+ cout << endl;
+}
-}