/* Symmetry is an interesting property in the mathematical world and particularly in matrix algebra. Your task is to determine if a given square matrix is symmetric. As a refresher, a matrix is a 2-dimensional array of elements. A square matrix is a matrix that has the same number of rows and columns (i.e., the size is N x N). Transposition is one common operation that can be performed on a matrix. In this operation, the k-th row of the input matrix A becomes the k-th column in the output matrix B for all k=1,..,N. The square matrix A is symmetric if it is equivalent to its transpose B; that is, A = B. The first line of the input contains the size N of the square matrix. The next N lines contain N elements each, representing the elements of the matrix. The output is simply "Symmetric" if the matrix is symmetric or "Not symmetric" if it is not. HINT: Transposition is really just a reflection over the main diagonal of the matrix. ====== SAMPLE RUN ======= 2 0 2 2 0 Symmetric ========================= ====== SAMPLE RUN ======= 3 4 2 1 2 5 3 1 3 9 Symmetric ========================= ====== SAMPLE RUN ======= 3 1 2 3 4 5 6 7 8 9 Not symmetric ========================= */ #include #include int main() { int n, i, j; int valid; scanf("%d", &n); int matrix[n][n]; // Read in matrix for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) scanf("%d", &matrix[i][j]); valid = 1; // Check for symmetry for(i = 0; valid && i < n; ++i) for(j = i + 1; valid && j < n; ++j) if(matrix[i][j] != matrix[j][i]) valid = 0; if(valid) printf("Symmetric.\n"); else printf("Not symmetric.\n"); system("pause"); return 0; }