لعبة المزرعة السعيدة لعبة الفراخ

جافا : برنامج يقارن بين مصفوفتين اذا كانتا متماثلتين ام لا

import java.util.Scanner;


public class Tryb {
public static void main (String [ ]aht){
Scanner in = new Scanner (System.in);
System.out.println("Enter the elements of the first Array");
int lengtha=in.nextInt();
int [] a = new int [lengtha];
a[0]=lengtha;
for (int i=1;i<lengtha;i++)a[i]=in.nextInt();
System.out.println("Enter the elements of the second Array");
int lengthb=in.nextInt();
int [] b = new int [lengthb];
b[0]=lengthb;
for (int i=1;i<lengthb;i++)b[i]=in.nextInt();
System.out.println("Are the the same ? " + check(lengtha,lengthb,a,b));
}

private static boolean check(int lengtha, int lengthb, int[] a, int[] b) {
if (lengtha!=lengthb)return false ;
for (int i=0;i<lengtha;i++)
if (a[i]!=b[i])return false ;
return true;
}

}

0 التعليقات:

لعبة من سيربح المليون لعبة زوما