開啟章節選單
11349 Symmetric Matrix
程式碼
#include <stdio.h> int main(){ int t,n,N[100][100],i,j,k,x,y,check,out[301]; scanf("%d",&t); for(k=1;k<=t;k++){ scanf(" N = "); scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<n;j++){ scanf("%d",&N[i][j]); } } check = 1; for(x=0;x<n;x++){ for(y=0;y<n;y++){ if(N[x][y]!=N[n-1-x][n-1-y] || N[x][y] < 0){ check = 0; break; } } if(check == 0) break; } out[k]=check; } for(k=1;k<=t;k++){ if(out[k]==1) printf("Test #%d: Symmetric.\n",k); if(out[k]==0) printf("Test #%d: Non-symmetric.\n",k); } return 0; }