2024-08-31 01:25:52 +05:30
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
class SymmMatrixCheck {
|
|
|
|
|
|
|
|
public static void main(String args[]) {
|
|
|
|
Scanner sc = new Scanner(System.in);
|
2024-08-31 09:26:09 +05:30
|
|
|
System.out.print("Enter the number of rows and columns in the matrix: ");
|
2024-08-31 01:25:52 +05:30
|
|
|
int m = sc.nextInt();
|
|
|
|
|
2024-08-31 09:26:09 +05:30
|
|
|
int a[][] = new int[m][m];
|
2024-08-31 01:25:52 +05:30
|
|
|
for (int i = 0; i < m; i++) {
|
2024-08-31 09:26:09 +05:30
|
|
|
for (int j = 0; j < m; j++) {
|
2024-08-31 01:25:52 +05:30
|
|
|
System.out.print(
|
|
|
|
"Enter the element at (" + i + "," + j + "): "
|
|
|
|
);
|
|
|
|
a[i][j] = sc.nextInt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isSymmetric = true;
|
|
|
|
for (int i = 0; i < m; i++) {
|
2024-08-31 09:26:09 +05:30
|
|
|
for (int j = 0; j < m; j++) {
|
2024-08-31 01:25:52 +05:30
|
|
|
if (i != j && a[i][j] != a[j][i]) {
|
|
|
|
isSymmetric = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isSymmetric) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSymmetric) {
|
|
|
|
System.out.println("The matrix is symmetric.");
|
|
|
|
} else {
|
|
|
|
System.out.println("The matrix is not symmetric.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|