الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كود الجافا

مغلق
بدأه قلب شامخ في 7 أكتوبر 2007 · 2 رد · 634 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

أشكركم كثيرا

هذا هو الكود بلغة الجافا

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");

}

}

}

#2

السلام عليكم و رحمة الله و بركاته

هناك بعض الأخطاء اللغوية syntax errors قمت بتصويبها و تأكدت من الناتج و إليك الكود بعد التعديل:

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();
System.out.println();

}



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 (S1==S2[j])


{


efound=1;


break;


}


}



if (efound==0){

//System.out.println ("   "+S1+"!="+S2[j]);


System.out.print ("   "+S1);

}



} 
System.out.println();

}

}
#3

الأخطاء قد ظهرت بسبب النسخ

وأشكرك على كل حال ...

وبالمناسبة لقد وضعت هذا الكود هنا بالخطأ :lol:

هذا الموضوع مغلق.

مواضيع مشابهة