Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 05 / task16_sem3.cpp
diff options
context:
space:
mode:
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;
+}
-}