-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1827(1).cpp
executable file
·50 lines (38 loc) · 1.14 KB
/
1827(1).cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// #1827 Square Array IV by Neilor Tonin
#include <iostream>
using namespace std;
int main(void){
unsigned short int size;
unsigned short int i, j;
unsigned short int inside;
char current;
while(std::cin >> size){
inside = int((size-1)/3);
for (i = 0; i < size; i++){
for (j = 0; j < size; j++){
// outside square.
current = '0';
// Main diagonal.
if (i == j){
current = '2';
}
// Second diagonal.
if (i == size - 1 - j){
current = '3';
}
// inside square.
if ( ((i >= inside) && (i < size-inside)) && ((j >= inside) && (j <= size-inside-1)) ){
current = '1';
}
// center.
if ((i == size/2) && (j == size/2)){
current = '4';
}
// output.
std::cout << current;
}
std::cout << std::endl;
}
std::cout << std::endl;
}
}