-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBC1435.cpp
More file actions
35 lines (32 loc) · 840 Bytes
/
BC1435.cpp
File metadata and controls
35 lines (32 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;
int main()
{
int i, j, k, e, N;
int Array[100][100];
while (cin >> N && N)
{
for (i = 0, e = N - 1; i <= e; i++, e--)
{
for (j = 0, k = N - 1; j <= k; j++, k--)
{
if (j >= i + 1)
Array[i][j] = Array[i][k] = Array[e][j] = Array[e][k] = i + 1;
else
Array[i][j] = Array[i][k] = Array[e][j] = Array[e][k] = j + 1;
}
}
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
cout << setw(3) << right << Array[i][j]; // right justified
if (j != N - 1)
cout << " ";
}
cout << endl;
}
cout << endl;
}
return 0;
}