Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Identitymatrix {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int i=scan.nextInt();
- int j=scan.nextInt();
- int a[][]=new int[i][j];
- for(int k=0;k<i;k++)
- {
- for(int l=0;l<j;l++)
- {
- a[k][l]=scan.nextInt();
- }
- }
- //int a[][]={{1,0,0},{0,1,0},{0,0,1}};
- boolean b= true;
- for(int i1=0;i1<i;i1++)
- {
- for(int j1=0;j1<j;j1++)
- {
- if(i1==j1)
- {
- if(a[i1][j1]==1)
- {
- b=true;
- }
- else
- {
- b=false;
- }
- }
- else
- {
- if(a[i1][j1]==0)
- {
- b=true;
- }
- else
- {
- b= false;
- }
- }
- }
- }
- System.out.println(b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement