Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Identitymatrix {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int i=scan.nextInt();
  7. int j=scan.nextInt();
  8. int a[][]=new int[i][j];
  9. for(int k=0;k<i;k++)
  10. {
  11. for(int l=0;l<j;l++)
  12. {
  13. a[k][l]=scan.nextInt();
  14. }
  15. }
  16. //int a[][]={{1,0,0},{0,1,0},{0,0,1}};
  17. boolean b= true;
  18. for(int i1=0;i1<i;i1++)
  19. {
  20. for(int j1=0;j1<j;j1++)
  21. {
  22. if(i1==j1)
  23. {
  24. if(a[i1][j1]==1)
  25. {
  26. b=true;
  27. }
  28. else
  29. {
  30. b=false;
  31. }
  32. }
  33. else
  34. {
  35. if(a[i1][j1]==0)
  36. {
  37. b=true;
  38. }
  39. else
  40. {
  41. b= false;
  42. }
  43. }
  44. }
  45. }
  46. System.out.println(b);
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement