السلام عليكم و رحمة الله
عندي لمشروع مادة الداتا ستركشر المطلوب عمل هذا البرنامج
و هذا الكود للبرنامج اششتغل تمام كل المطلوب ما عادا اخر مطلوب من السؤال
اللي هوا مقارنة حروف اللغة المدخلة مع حروف الكلمة المدخلة
هذا الكود
import java.util.Scanner;
import java.io.*;
public class Class1
{
int top=-1;
char stack[]=new char[10];
public static void push(Class1 s , char a)
{
s.top++;
s.stack[s.top]=a;
}
public static char pop(Class1 s)
{
char a;
a=s.stack[s.top];
s.top--;
return (a);
}
public static void main (String[]args) throws Exception
{
Class1 s1=new Class1();
Class1 s2=new Class1();
Class1 s3=new Class1();
Scanner input =new Scanner(System.in);
char z;
int a,a1,n,r=0;
char ch,ch1,ch2;
System.out.println("========================================================================= ");
System.out.println("Enter 10 letters for the language , , , WITHOUT SPACES BETWEEN THE LETTERS");
for(int i=0;i<10;i++)
{
ch=(char) System.in.read();
s1.push(s1,ch);
}
System.out.println("========================================================================= ");
System.out.println("The valid characters of your language are:");
for(int i=1;i<=10;i++)
{
System.out.print(i);
System.out.print(") ");
System.out.println( s1.pop(s1));
}
System.out.println("========================================================================= ");
System.out.println("Enter the number of the letters of the word you want to check");
n=input.nextInt();
ch=(char)System.in.read();
n=n-10;
System.out.println("========================================================================= ");
System.out.println("Enter the word you need to check");
for(int i=0;i<10;i++)
{
ch=(char) System.in.read();
s2.push(s2,ch);
}
for(int i=0;i<n;i++)
{
ch1=s2.pop(s2);
for(int j=0;j<n;j++)
{
ch2=s1.pop(s1);
if(ch1==ch2)
r++;
s3.push(s3,ch2);
}
}
if(r==n)
{
System.out.println("========================================================================= ");
System.out.println("The word is part of the language");
}
else
{
System.out.println("========================================================================= ");
System.out.println("The word is not a part of the langauge");
}
}
}و هذا الاوت بوت
المشكلة محددة بالخط الاحمر
لما ادخلت حروف من ضمن اللغة اللي ادخلتها يطلع انه not a part






