Created
May 30, 2017 11:16
-
-
Save apple8803351/96c01638b92ff2b3354d922573b42196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX 1 | |
int main(int argc, char *argv[]) { | |
int i,j,k; | |
int t, n; | |
char temp1[MAX], temp2[MAX]; | |
while(scanf("%d", &t) != EOF) | |
{ | |
for(k = 1 ; k <= t ; k++) | |
{ | |
scanf("%s%s%d", temp1, temp2, &n); //把N = 分別存到 temp1 和 temp2 | |
long long int matrix[n][n]; //超長整數 | |
//存入 記住: 陣列也需要加入& | |
for(i = 0 ; i < n ; i++) | |
{ | |
for(j = 0 ; j < n ; j++) | |
{ | |
scanf("%lld", &matrix[i][j]); | |
} | |
} | |
int key = 1; | |
//比對矩陣 | |
for(i = 0 ; i <= (n - 1) / 2 ; i++) | |
{ | |
for(j = 0 ; j < n ; j++) | |
{ | |
if(matrix[i][j] < 0) //如果出現負號直接出局 | |
{ | |
key = 0; | |
} | |
else if(matrix[i][j] != matrix[n - i - 1][n - j - 1]) //對稱比對 | |
{ | |
key = 0; | |
} | |
if(key == 0) | |
{ | |
goto end; //第一次使用goto覺得不錯用 不用寫兩次break跳兩次迴圈 | |
} | |
} | |
} | |
end: | |
if(key) | |
{ | |
printf("Test #%d: Symmetric.\n", k); | |
} | |
else | |
{ | |
printf("Test #%d: Non-symmetric.\n", k); | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment