Question: Symmetric MatrixACCEPTED...Among the simplest i have seen.
____________________________________________________________________
____________________________________________________________________
#include "iostream.h"
#include "math.h"
int main()
{
int t;
cin >>t;
for(int i = 1; i <= t; i++) {
cin.ignore(4);
int n, sym = 1;
cin >> n;
long long int mat[n][n];
for(int j = 0; j < k =" 0;">> mat[j][k];
for(int j = 0; j <= ceil(n/2); j++) for(int k = 0; k < n; k++) if(mat[j][k] < 0 || mat[j][k] != mat[n - j - 1][n - k - 1]) sym = 0;
cout << "Test #" << i << ": ";
if(sym) cout << "Symmetric.\n";
else cout << "Non-symmetric.\n";
}
return 0;
}
____________________________________________________________________
Friday, December 7, 2007
Symmetric Matrix
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment