# UVA 11349 Symmetric Matrix
## 題目連結 [UVA 11349](https://vjudge.net/problem/UVA-11349)
### 題目內容
You‘re given a square matrix M. Elements of this matrix are Mij : {0 < i < n, 0 < j < n}. In this problem you’ll have to find out whether the given matrix is symmetric or not.
Definition: Symmetric matrix is such a matrix that all elements of it are non-negative and symmetric with relation to the center of this matrix. Any other matrix is considered to be non-symmetric. For example:
$$
M=\left[
\begin{matrix}
5 & 1 & 3 \\
2 & 0 & 2 \\
3 & 1 & 5
\end{matrix}
\right]
$$
is symmetric
$$
M=\left[
\begin{matrix}
5 & 1 & 3 \\
2 & 0 & 2 \\
0 & 1 & 5
\end{matrix}
\right]
$$
is not symmetric, because 3 \not= 0
All you have to do is to find whether the matrix is symmetric or not. Elements of a matrix given in the input are −2^32^ ≤ Mij ≤ 2^32^ and 0 < n ≤ 100.
### 輸入限制
First line of input contains number of test cases T ≤ 300. Then T test cases follow each described in the following way. The first line of each test case contains n – the dimension of square matrix. Then n lines follow each of then containing row i. Row contains exactly n elements separated by a space character. j-th number in row i is the element Mij of matrix you have to process.
### 輸出限制
For each test case output one line ‘Test #t: S’. Where t is the test number starting from 1. Line S is equal to ‘Symmetric’ if matrix is symmetric and ‘Non-symmetric’ in any other case.
### 解題思路
1.輸入的N=3利用char c輸入兩次加一次x處理
2.矩陣從1開始算,以中間算對稱的點為x+1-i
3.要注意矩陣中不能有負數,需要偵測是否有小餘0的數
### 程式碼
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
char c;
int x,kase=1;
long long a[105][105];
cin>>n;
while(n--){
cin>>c>>c>>x;
int ty=1;
memset(a,0,sizeof a);
for(int i=1;i<=x;i++){
for(int j=1;j<=x;j++){
cin>>a[i][j];
if(a[i][j]<0){
ty=0;
}
}
}
if(ty==1){
for(int i=1;i<=x;i++){
for(int j=1;j<=x;j++){
if(a[i][j]!=a[x+1-i][x+1-j]){
ty=0;
break;
}
}
}
}
if(ty){
cout<<"Test #"<<kase++<<": Symmetric."<<endl;
}
else{
cout<<"Test #"<<kase++<<": Non-symmetric."<<endl;
}
}
}
```
## 測資
### Sample input
2
N = 3
5 1 3
2 0 2
3 1 5
N = 3
5 1 3
2 0 2
0 1 5
### Sample output
Test #1: Symmetric.
Test #2: Non-symmetric.
## 中文題目連結 [zerojudge e513](https://zerojudge.tw/ShowProblem?problemid=e513)