Topic 1180: Symmetric matrices
time limit:1 seconds
Memory limit:32 MB
Special question: No
submitted:2518
Resolution:1295
-
Title Description:
-
Enter an n-dimensional matrix to determine whether it is symmetrical.
-
Input:
-
Enter the first line to include a number: N (1<=n<=100), which represents the dimension of the matrix.
The next n rows, each containing the n number, represent the elements of the n*n matrix.
-
Output:
-
There may be multiple sets of test data, for each set of data,
Output "yes!" Represents the matrix as a symmetric matrix.
Output "no!" Indicates that the matrix is not a symmetric matrix.
-
Sample input:
-
416 19 16 6 19 16 14 5 16 14 16 3 6 5 3 16 21 23 4
-
Sample output:
-
yes! No!
-
Source:
- 2000 Huazhong University of Science and technology computer research life test real problem
1#include <iostream>2#include <cstring>3#include <cstdio>4 using namespacestd;5 intmap[ the][ the];6 intMain () {7 //freopen ("D:\\input.txt", "R", stdin);8 intN;9 while(cin>>N) {Ten inti,j; One for(i=1; i<=n;i++){ A for(j=1; j<=n;j++){ -scanf"%d",&map[i][j]); - } the } - for(i=1; i<=n;i++){ - for(j=1; j<=n;j++){ - if(map[i][j]!=map[i][n-J]) { +i=n+2; - Break; + } A } at } - if(i==n+1){ -cout<<"yes!"<<Endl; - Continue; - } - for(i=1; i<=n;i++){ in for(j=1; j<=n;j++){ - if(map[i][j]!=map[n-i] [j]) { toi=n+2; + Break; - } the } * } $ if(i==n+1){Panax Notoginsengcout<<"yes!"<<Endl; - Continue; the } + A for(i=1; i<=n;i++){ the for(j=1; j<=n;j++){ + if(map[i][j]!=Map[j][i]) { -i=n+2; $ Break; $ } - } - } the if(i==n+1){ -cout<<"yes!"<<Endl;Wuyi Continue; the } - Wu for(i=1; i<=n;i++){ - for(j=1; j<=n;j++){ About if(map[i][j]!=map[n-j][n-i]) { $i=n+2; - Break; - } - } A } + if(i==n+1){ thecout<<"yes!"<<Endl; - Continue; $ } thecout<<"no!"<<Endl; the } the return 0; the}
2000 the computer research of Huazhong University of Science and technology real problem symmetry matrix