-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
98 lines (82 loc) · 1.71 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
using namespace std;
bool CheckSymmetric(long long M[][10] , int size , int lmt)
{
if((size == 1) && (M[0][0] < 0))
{
return false;
}
if((size == 1) && M[0][0] > 0)
{
return true;
}
for(int col = 0 ; col < lmt ; col++)
{
for(int row = 0 ; row < size ; row++)
{
if(M[row][col] < 0)
{
return false;
}
if(M[row][col] != M[size - 1 - row][size - 1 - col])
{
return false;
}
}
}
return true;
}
int main()
{
int t,N, limit;
long long mat[10][10];
string result;
cin >> t;
for(int i = 0 ; i < t ; i++)
{
string instr,h;
cin.ignore();
getline(cin,instr);
if(instr[instr.size() - 2] == ' ')
{
h = "0";
}
h = instr[instr.size() - 1];
N = atoi(h.c_str());
for(int k = 0 ; k < N ; k++)
{
for(int h = 0 ; h < N ; h++)
{
cin >> mat[k][h];
}
}
if((N % 2) == 1)
{
limit = (N / 2) + 1;
}
if((N % 2) == 0)
{
limit = (N / 2) ;
}
if(CheckSymmetric(mat,N,limit))
{
result.push_back('s');
}
else
{
result.push_back('n');
}
}
for(unsigned int s = 0 ; s < result.size() ; s++)
{
cout << "Test #" << (s + 1) << ":";
if(result[s] == 's')
{
cout << " Symmetric." << endl;
}
else if(result[s] == 'n')
{
cout << " Non-symmetric." << endl;
}
}
}