#include <stdio.h> #include <stdlib.h> int main() { int t; scanf("%d", &t); if(t > 300) return 0; // cases T <= 300; int c = 1; // c for output; while(t--){ int N = 0; char line[16]; int s = 1; scanf("%c", &line); fgets(line, sizeof(line), stdin); sscanf(line, "N = %d", &N); int **M = (int**)malloc(sizeof(int*) * N); // int 2D array for(int i = 0; i < N; i++){ // int 1D array *(M + i) = (int*)malloc(sizeof(int) * N); } for (int i = 0; i < N; i++) { // scan the number into arrays for (int j = 0; j < N; j++) { scanf("%d", (*(M + i) + j)); } } for(int i = 0; i < N; i++){ // check the symmerty number for(int j = 0; j < N; j++){ if(*(*(M + i) + j) != *(*(M + (N - 1 - i)) + (N - 1 - j))){ s = 0; break; } } } if(s == 1) printf("Test #%d: Symmetric.\n", c); else printf("Test #%d: Non-symmetric.\n", c); for(int i = 0; i < N; i++){ free(*(M + i)); // Free 2D } free(M); // Free 1D c++; // case number } return 0; } |