Update OOP/Java/Lab/Week4/SymmMatrixCheck.java
This commit is contained in:
parent
3c0de68177
commit
1903c1a586
@ -4,14 +4,12 @@ class SymmMatrixCheck {
|
|||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
System.out.print("Enter the number of rows in the matrix: ");
|
System.out.print("Enter the number of rows and columns in the matrix: ");
|
||||||
int m = sc.nextInt();
|
int m = sc.nextInt();
|
||||||
System.out.print("Enter the number of colums in the matrix: ");
|
|
||||||
int n = sc.nextInt();
|
|
||||||
|
|
||||||
int a[][] = new int[m][n];
|
int a[][] = new int[m][m];
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < m; j++) {
|
||||||
System.out.print(
|
System.out.print(
|
||||||
"Enter the element at (" + i + "," + j + "): "
|
"Enter the element at (" + i + "," + j + "): "
|
||||||
);
|
);
|
||||||
@ -21,7 +19,7 @@ class SymmMatrixCheck {
|
|||||||
|
|
||||||
boolean isSymmetric = true;
|
boolean isSymmetric = true;
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < m; j++) {
|
||||||
if (i != j && a[i][j] != a[j][i]) {
|
if (i != j && a[i][j] != a[j][i]) {
|
||||||
isSymmetric = false;
|
isSymmetric = false;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user