أشكركم كثيرا
هذا هو الكود بلغة الجافا
import java.util.Scanner;
public class Exercise4 {
Scanner input = new Scanner(System.in);
private static int n1,n2;
public static void main (String args[])
{
Scanner input = new Scanner(System.in);
System.out.print("Please enter the length of the first array S1:");
n1=input.nextInt();
System.out.print("Please enter the length of the Second array S2:");
n2=input.nextInt();
System.out.println();
Exercise4 AA = new Exercise4();
AA.array1();
AA.array2();
AA.thedifference(); }
private int S1[]= new int[n1];
private int S2[]= new int[n2];
public void array1()
{
System.out.print("Please enter the elements of the array S1:");
for (int i=0;i<S1.length;i++)
S1=input.nextInt();
}
public void array2()
{
System.out.print("Please enter the elements of the array S2:");
for (int j=0;j<S2.length;j++)
S2[j]=input.nextInt();
System.out.println();
}
public void thedifference()
{
System.out.print("The elements in the array S1 not found in S2:");
for(int i=0;i<S1.length;i++)
{
int efound=0;
for (int j=0;j<S2.length;j++)
{
if (S2[j]==S1)
{
efound=1;
break;
}
}
if (efound==0)
System.out.print(S1);
System.out.print("\t");
}
}
}