Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package javaLab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PostLab {
  6. public static void main (String[] args){
  7. int arr[][] = new int [3][3];
  8. int arr2[][] = new int [3][3];
  9. Scanner input = new Scanner(System.in);
  10. System.out.println("Please fill the first matrix..");
  11. for (int i=0;i<3;i++){
  12. for (int j=0;j<3;j++)
  13. {
  14. System.out.print("Row Number "+(i+1)+" and coulum number " + (j+1)+ " : ");
  15. arr[i][j]=input.nextInt();
  16. }}
  17. System.out.println("Please fill the second matrix..");
  18. for (int a=0;a<3;a++){
  19. for (int j=0;j<3;j++)
  20. {
  21. System.out.print("Row Number "+(a+1)+" and coulum number " + (j+1)+ " : ");
  22. arr2[a][j]=input.nextInt();
  23. }
  24. }
  25. boolean flag=false;
  26. for (int b=0;b<3;b++){
  27. for (int j=0;j<3;j++)
  28. {
  29. if(arr[b][j]!=arr2[b][j]){
  30. flag=true;
  31. break;
  32. }
  33. }
  34. }
  35. if(flag==true)
  36. System.out.println("the two matrices are NOT equal !");
  37. else
  38. System.out.println("the two matrices are equal");
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement