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

مشكله فى تضمين الـ Queue

بدأه om ahmed في 20 أبريل 2012 · 4 رد · 462 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

أخواني كتبت أكواد لبرنامج عن الطابور queue

بس عليه اضافات الداله اللي راح تضيف للطابور فيها شرطين إذا كانت تحقق شرط عدم امتلاء الطابور يدخل ويختبر شرط اخر هل توفرت شروط التسجيل إذا نعم

يتم ادخال العنصر للطابور ولكن المشكله عندي انه يكتب لايوجد مقاعد شاغره على طول بالرغم انه انا لحد الان مادخلت ولا طالب (( طبعا فكرة البرنامج عن الابتعاث الخارجي))

شي ثاني كيف اقدر ادخل العناصر للطابور عن طريق دوارة يعني يدخل المستخدم عدد من المرات وبعدين تتم طباعة الطابور جربتها ولكن صار مايعرض الا اخر ادخال فقط

أكوادي جاهزه ومافيها اي خطا بس ياريت تساعدوني ليه تطلع النتيجه غلط والسؤال الثاني

جزى الله من يجاوب كل الخير

#include<iostream.h>
#include<conio.h>
#define MAXSIZE 5
struct sc{
int front,rear;
int queue[MAXSIZE];
}s;
void information();
int check();
int requirements();
void registration();
void comp();
void accepted();
void cancel();
void accepted();
void main(){
information();
check();
requirements();
registration();
comp();
accepted();
cancel();
accepted();
getch();}
void information(){
cout<<"Hello to you in  program of Custodian  Scholarship"<<endl<<endl;
cout<<"the most important service in our program"<<endl<<endl;
cout<<" 1.basic monthly salary for the student"<<endl<<endl;
cout<<" 2.allowance for wife"<<endl<<endl;
cout<<" 3.allowance for children"<<endl<<endl;
cout<<"if you want to know more information please visit the following website"<<endl<<endl;
cout<<"www.mohe.gov.sa/ar/studyaboard/kingabdulla-hstages"<<endl<<endl;
}
int check(){
int pa;
cout<<"please enter apassword"<<endl;
cin>>pa;
if(pa==1231)return(1);
else return(0);}
int full(){
if (s.rear==MAXSIZE-1) return(1);
else return(0);}
int empty(){
if (s.front==s.rear+1)
return(1);
else
return(0);
}
int requirements(){
char name[10],nat[10];
int m,dl,fe,se,t,y;
cout<<"enter name"<<endl;
cin>>name;
cout<<"what is your nationality?"<<endl;
cin>>nat;
cout<<"are you afull time study and without ajob(1.yes or 2.no)"<<endl;
cin>>m;
cout<<"what is your degree in high school?"<<endl;
cin>>dl;
cout<<"what is the degree of general capacity test?"<<endl;
cin>>fe;
cout<<"what is the degree of achievement test?"<<endl;
cin>>se;
cout<<"How long have you graduate from secondary?"<<endl;
cin>>t;
cout<<"how old are you?"<<endl;
cin>>y;
if(nat=="saudi" && m==1 && dl>=90 && fe>=70 && se>=77 && t<=3 && y<=22)return (1);
else return(0);
}
void registration(){
if(full==0){
if(requirements()==1){
cout<<"enter your passport number"<<endl;
s.rear=s.rear+1;
cin>>s.queue[s.rear];}
else{
cout<<"Can not be registered for not meet the conditions"<<endl;}
}
else{
cout<<"Can not be registered no seats currently vacant"<<endl;}
}
void comp(){
int single,children,total,convert;
cout<<"Are you married or single(1.single or 2.married)"<<endl;
cin>>single;
if(single==1){
total=1840;
cout<<"Will be paid an amount of"<<" "<<total<<"dolars"<<endl;
convert=3.75*1840;
cout<<"in saudi reals ="<<convert<<"reals"<<endl;}
else{
cout<<"how many children do you have"<<endl;
cout<<"If you do not have children write (0)"<<endl;
cin>>children;
total=1840+600+(children)*350;
cout<<"Will be paid an amount of"<<" "<<total<<"dolars"<<endl;
convert=3.75*total;
cout<<"in saudi reals ="<<convert<<"reals"<<endl;
}}
void cancel(){
if(empty()==1){
cout<<"No requests for cancellation"<<endl;}
else{
cout<<"\n"<<s.queue[s.front]<<"has been canceled"<<endl;
s.front=s.front+1;}
}
void accepted(){
int i;
if(empty()==1){
cout<<"No students are accepted"<<endl;
}
else{
cout<<"anumber of accepted student is"<<endl;
for(i=s.front;i<=s.rear;i++){
cout<<i<<"   "<<s.queue<<endl;}
}
}
#2

السلام عليكم

لا توجد دالة إضافة فى هذا البرنامج حتى تستطيعى السحب من queue

تفضلى بزيارة هذا الرابط به برنامج لإستخدام queue للإضافة والسحب

لاتحسبن العلم ينفع وحده مالم يتوج ربه بخلاق

لا إله إلا أنت سبحانك إني كنت من الظالمين

#3

أخي أنا طالبة وهذي هي داله الاضافة عندي بس انا اضفت عليها شروط

void registration(){
if(full==0){
if(requirements()==1){
cout<<"enter your passport number"<<endl;
s.rear=s.rear+1;
cin>>s.queue[s.rear];}
else{
cout<<"Can not be registered for not meet the conditions"<<endl;}
}
else{
cout<<"Can not be registered no seats currently vacant"<<endl;}
}

بالتحديد هذا هو الجزء الخاص بالاضافة ياريت تساعدني لو عندك معلومه

s.rear=s.rear+1;
cin>>s.queue[s.rear];

اطلعت على الرابط لكن الطريقة لم افهمها مختلفة عما ادرسه الان

تم تعديل هذه المشاركة بواسطة om ahmed في 20 أبريل 2012 في 11:56

#4

السلام عليكم

الكود به أخطاء منطقية ولغوية أيضاً , ما الفائدة من إستدعاء دالة تعود بقيمة ولا تسند لمتغير أو يتم إجراء أى عملية عليها كما هو الحال فى الدوال الموجودة فى الدالة الأساسية .

ويجب عند إستدعاء الدالة وضع الأقواس () الفارغة إذا كانت لا تأخذ قيم كما فى استخدامك الخاطئ للدالة full فى الكود السابق , فلهذا لا يتم إكمال عمل الدالة بشكل صحيح .

وأيضاً تعريف متغيرات صحيحة سوف يتم تخزين قيم كسرية بها .

وأيضاً للــ queue قواعد فى الإضافة لها والسجب منها فيجب عليك دراسة queue جيداً لتستطيع التعامل معها بشكل جيد , مع تنظيم الكود بشكل افضل من هذا .

لاتحسبن العلم ينفع وحده مالم يتوج ربه بخلاق

لا إله إلا أنت سبحانك إني كنت من الظالمين

#5

لو تتكرم وتعلمني بأماكن الأخطاء حتى أتمكن بإصلاحها وبالنسبة للqueue احنا نتعلمها بهذي الطريقة

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