Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaLab;
- import java.util.Scanner;
- public class PostLab {
- public static void main (String[] args){
- int arr[][] = new int [3][3];
- int arr2[][] = new int [3][3];
- Scanner input = new Scanner(System.in);
- System.out.println("Please fill the first matrix..");
- for (int i=0;i<3;i++){
- for (int j=0;j<3;j++)
- {
- System.out.print("Row Number "+(i+1)+" and coulum number " + (j+1)+ " : ");
- arr[i][j]=input.nextInt();
- }}
- System.out.println("Please fill the second matrix..");
- for (int a=0;a<3;a++){
- for (int j=0;j<3;j++)
- {
- System.out.print("Row Number "+(a+1)+" and coulum number " + (j+1)+ " : ");
- arr2[a][j]=input.nextInt();
- }
- }
- boolean flag=false;
- for (int b=0;b<3;b++){
- for (int j=0;j<3;j++)
- {
- if(arr[b][j]!=arr2[b][j]){
- flag=true;
- break;
- }
- }
- }
- if(flag==true)
- System.out.println("the two matrices are NOT equal !");
- else
- System.out.println("the two matrices are equal");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement