حـ قطرة بر
28-01-2004, 03:09 AM
لسلام عليكم ورحمة الله وبركاته
هذا ثاني موضوع لي بالقسم
وأتمنى يكون مفيد
راح أحل لكم سؤال موجود في كتاب الجامعة
لكن السؤال مش محلول في الكتاب .. عشان أطمنكم الدكتور عطاني عليه علامة كامله
عشان كذا تشجعت أكتب الخل لكم
أسم الكتاب : HOW TO PROGRAM
C++ ?
السؤال موجود صفحة 296
ورقم السؤال : 4.20
بأختصار شديد السؤال يقول :
أكتب برنامج ... يسمح للمستخدم حجز للرحلات عن طريقه
مع العلم أنك تملك 10 كراسي في الرحله
ولديك رحله أخرى بعد 3 ساعات
ويجب ان تصنف الركاب على حسب الدرجة الأولى والدرجة السياحية
وتقسم كلا منهما إلى مدخن وغير مدخن
هذا بأختصار شديد
وإلى حاب يقدر يرجع للكتاب
// plane programming
// page 296 E (4.20)
# include <iostream.h>
# include <iomanip.h>
# include <stdlib.h>
# include <stdio.h>
# include <time.h>
// ---------------------------- Function For First Class --------
int FirstClass (int a[],int &l)
{
char y;
int j=0;
if (j!=4)
{
for (j=0; j<5; j++)
{
if (a[j]==0)
{
a[j]++;
cout <<"\n\n\tYour seeat in First Class part";
cout <<"\n\n\tTheNumber Of Your Seeat Is = "<<j+1;
cout <<"\n\nDo You Need Set In Nonsmoking"<<"Y = Yes && N = No : ";
cin >>y;
if (y=='Y'||y=='y')
cout <<"\n\n\tYou seeat in *Nonsmoking* part ";
if (y=='N'||y=='n')
cout <<"\n\n\tYou seeat in *smoking* part ";
cout <<"\n\n\n\tThanks For Use My System .. \n\n\n\n\n\n\n\n\n" ;
break;
}
else
continue;
}
}
if (j==5)
{
cout <<"\n\nThere is no place we are sorry about that";
cout <<"\n\nNext Flight Leave In 3 Hours ";
cout << "\n\nYou can stay in Economy part if you need that try agin and choose 2"<<"\n\n\n\n\n";
}
return --l;
}
// ------------------------- Economy -----------------
void Economy (int a[],int &l)
{
int j=0;
char y;
if (j!=9)
{
for (j=5; j<10; j++)
{
if (a[j]==0)
{
a[j]++;
cout <<"\n\n\tYour seeat in Economy part";
cout <<"\n\n\tThe Number of your seeat is = "<<j+1;
cout <<"\n\nDo You Need Set In Nonsmoking"<<"Y = Yes && N = No : ";
cin >>y;
if (y=='Y'||y=='y')
cout <<"\n\n\tYou seeat in *Nonsmoking* part ";
if (y=='N'||y=='n')
cout <<"\n\n\tYou seeat in *smoking* part ";
cout <<"\n\n\n\tThanks For Use My System .. \n\n\n\n\n\n\n\n\n\n";
break;
}
else
continue;
}
}
if (j==10)
{
cout <<"\n\nThere is no place we are sorry about that";
cout <<"\n\nNext Flight Leave In 3 Hours "<<"\n\n\n\n\n\n";
}
}
// ------------------------------------- main -------------
void main ()
{
int s;
const int size=10;
int a[size];
for (int i=0; i<size; i++)
a[i]=0;
for (int l=0; l<size; l++)
{
cout << " \t\t\tHi\n\n\t\tThinks for use my system\n";
cout << "\nIf you need stay in 'first Class' please choose 1: ";
cout << "\nIf you need stay in 'Economy' please choose 2:\n ";
cin >> s;
if (s==1)
FirstClass(a,l);
if (s==2)
Economy(a,l);
if (s!=1&&s!=2)
cout << "\n\nPlease Try Again And Choose Right Number "<<"\n\n\n\n\n";
}
}
هذا هو الحل
أتمنى يكون سهل عليكم
هذا ثاني موضوع لي بالقسم
وأتمنى يكون مفيد
راح أحل لكم سؤال موجود في كتاب الجامعة
لكن السؤال مش محلول في الكتاب .. عشان أطمنكم الدكتور عطاني عليه علامة كامله
عشان كذا تشجعت أكتب الخل لكم
أسم الكتاب : HOW TO PROGRAM
C++ ?
السؤال موجود صفحة 296
ورقم السؤال : 4.20
بأختصار شديد السؤال يقول :
أكتب برنامج ... يسمح للمستخدم حجز للرحلات عن طريقه
مع العلم أنك تملك 10 كراسي في الرحله
ولديك رحله أخرى بعد 3 ساعات
ويجب ان تصنف الركاب على حسب الدرجة الأولى والدرجة السياحية
وتقسم كلا منهما إلى مدخن وغير مدخن
هذا بأختصار شديد
وإلى حاب يقدر يرجع للكتاب
// plane programming
// page 296 E (4.20)
# include <iostream.h>
# include <iomanip.h>
# include <stdlib.h>
# include <stdio.h>
# include <time.h>
// ---------------------------- Function For First Class --------
int FirstClass (int a[],int &l)
{
char y;
int j=0;
if (j!=4)
{
for (j=0; j<5; j++)
{
if (a[j]==0)
{
a[j]++;
cout <<"\n\n\tYour seeat in First Class part";
cout <<"\n\n\tTheNumber Of Your Seeat Is = "<<j+1;
cout <<"\n\nDo You Need Set In Nonsmoking"<<"Y = Yes && N = No : ";
cin >>y;
if (y=='Y'||y=='y')
cout <<"\n\n\tYou seeat in *Nonsmoking* part ";
if (y=='N'||y=='n')
cout <<"\n\n\tYou seeat in *smoking* part ";
cout <<"\n\n\n\tThanks For Use My System .. \n\n\n\n\n\n\n\n\n" ;
break;
}
else
continue;
}
}
if (j==5)
{
cout <<"\n\nThere is no place we are sorry about that";
cout <<"\n\nNext Flight Leave In 3 Hours ";
cout << "\n\nYou can stay in Economy part if you need that try agin and choose 2"<<"\n\n\n\n\n";
}
return --l;
}
// ------------------------- Economy -----------------
void Economy (int a[],int &l)
{
int j=0;
char y;
if (j!=9)
{
for (j=5; j<10; j++)
{
if (a[j]==0)
{
a[j]++;
cout <<"\n\n\tYour seeat in Economy part";
cout <<"\n\n\tThe Number of your seeat is = "<<j+1;
cout <<"\n\nDo You Need Set In Nonsmoking"<<"Y = Yes && N = No : ";
cin >>y;
if (y=='Y'||y=='y')
cout <<"\n\n\tYou seeat in *Nonsmoking* part ";
if (y=='N'||y=='n')
cout <<"\n\n\tYou seeat in *smoking* part ";
cout <<"\n\n\n\tThanks For Use My System .. \n\n\n\n\n\n\n\n\n\n";
break;
}
else
continue;
}
}
if (j==10)
{
cout <<"\n\nThere is no place we are sorry about that";
cout <<"\n\nNext Flight Leave In 3 Hours "<<"\n\n\n\n\n\n";
}
}
// ------------------------------------- main -------------
void main ()
{
int s;
const int size=10;
int a[size];
for (int i=0; i<size; i++)
a[i]=0;
for (int l=0; l<size; l++)
{
cout << " \t\t\tHi\n\n\t\tThinks for use my system\n";
cout << "\nIf you need stay in 'first Class' please choose 1: ";
cout << "\nIf you need stay in 'Economy' please choose 2:\n ";
cin >> s;
if (s==1)
FirstClass(a,l);
if (s==2)
Economy(a,l);
if (s!=1&&s!=2)
cout << "\n\nPlease Try Again And Choose Right Number "<<"\n\n\n\n\n";
}
}
هذا هو الحل
أتمنى يكون سهل عليكم