Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
classwork
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.println("enter the value of n"); int r=sc.nextInt(); int arr[][]=new int[r][r]; int i,j,s=0,h=0; System.out.println("enter the numbers"); for(i=0; i<r; i++) { for(j=0; j<r; j++) { arr[i][j]=sc.nextInt(); } } System.out.println("printing the original array"); for(i=0; i<r; i++) { for(j=0; j<r; j++) System.out.print(arr[i][j]+" "); System.out.println(); } int f=0,f2=0; for(i=0; i<r; i++) { for(j=0; j>r; j++) { if(i==j) { int k=arr[i][j]; if(k!=1) { f=1; break; } } else { int m=arr[i][j]; if(m!=0) { f2=1; break; } } } } if(f2==1 || f==1) System.out.println("it is a not identity matrix"); else System.out.println("it is a identity matrix"); } }
run
|
edit
|
history
|
help
0
continue
Sort an array of 0's 1's 2's 3 pointer approach
Binary Tree Max path Sum
1a
Quadratic equation
kochergina_3
jb7.0 extends.override
Counter.java
4a
Java Array List