Syntax 一个简单的C++;程序 #包括 使用名称空间std; int main() { char res[13][6]; int i,j; int=0; //所有变量的声明。 int第0行,第1行=0,第2行=0,第7行,第8行; int class_选项=0; 对于(i=0;i
正如forsvarir所说,您必须从Syntax 一个简单的C++;程序 #包括 使用名称空间std; int main() { char res[13][6]; int i,j; int=0; //所有变量的声明。 int第0行,第1行=0,第2行=0,第7行,第8行; int class_选项=0; 对于(i=0;i,syntax,Syntax,正如forsvarir所说,您必须从else(seat_row>row7)中删除;,,正如forsvarir所说,您必须从else(seat_row>row7)中删除;else语句不能有条件,即使有条件,您也不会在末尾加分号。使用此命令 #include<iostream> using namespace std; int main() { char res[13][6]; int i,j; int choices=0; // Declaration of all the vari
else(seat_row>row7)中删除;
,
,正如forsvarir所说,您必须从else(seat_row>row7)中删除;
else语句不能有条件,即使有条件,您也不会在末尾加分号。使用此命令
#include<iostream>
using namespace std;
int main()
{
char res[13][6];
int i,j;
int choices=0;
// Declaration of all the variable.
int row0,row1=0,row2=0,row7,row8;
int class_choices=0;
for(i=0;i<13;i++)
for(j=0;j<6;j++)
res[i][j]='*';
do
{
cout<<"Type of service provided. "<<endl;
cout<<"1. To enter your ticket type."<<endl;
cout<<"2. To display full reservation status."<<endl;
cout<<"3. Exit."<<endl<<endl;
cout<<"Enter your choice : ";
cin>>choices;
switch(choices)
{
// Type of class provided.
case 1:
cout<<endl<<"1. First Class"<<endl;
cout<<"2. Economy Class"<<endl;
cout<<"Enter your choice : ";
cin>>class_choices;
switch(class_choices)
{
// First Class.
case 1:
cout<<endl<<"Class specified by you : First Class";
row1=0;
row2=1;
break;
// Economy Class.
case 2:
cout<<endl<<"Class specified by you : Economy Class";
row0;
row1=2;
row2=12;
row7;
row8;
break;
// To indicate the user made a wrong choice.
default:
cout<<"WRONG CHOICE";
break;
}
// To indicate that "*" is available seats and "X" is occupied seats.
cout<<endl<<"* - Available Seats";
cout<<endl<<"X - Occupied Seats";
cout<<endl<<"Available seats for you are :: "<<endl;
cout<<"\t"<<"A B C D E F"<<endl;
for(i=row1;i<=row2;i++)
{
cout<<"Row "<<i+1;
for(j=0;j<6;j++)
{
cout<<"\t"<<res[i][j];
}
cout<<endl;
}
int seat_row;
cout<<endl<<"Enter your desired row : Row ";
cin>>seat_row;
// Condition for the non-smoking section.
if (seat_row>row0 && seat_row<row8)
{
int row0,row8;
cout<<"For your information, these are non-smoking section."<<endl;
}
// Condition for the smoking section.
else (seat_row>row7);
{
int row7;
cout<<"For your information, these are smoking section."<<endl;
}
if(seat_row<(row1+1) || seat_row>(row2+1))
{
cout<<"Invalid row selected";
system("pause");
break;
}
int seat;
cout<<endl<<"Enter your desired seat number (1-6) :";
cin>>seat;
if(seat<1 || seat>6)
{
cout<<"Invalid seat selected";
system("pause");
break;
}
if(res[seat_row-1][seat-1]!='X')
{
res[seat_row-1][seat-1]='X';
cout<<endl<<"Reserved";
}
else
{
cout<<endl<<" Owh,no! ! ! This seat is taken.";
break;
}
system("pause");
break;
// To display reservation status.
case 2:
cout<<endl<<"\tA B C D E F"<<endl;
for(i=0;i<13;i++)
{
cout<<"Row "<<i+1;
for(j=0;j<6;j++)
{
cout<<"\t"<<res[i][j];
}
cout<<endl;
}
system("pause");
// To exit.
case 3:
break;
}
}
while(choices!=3);
return 0;
}
希望这能有所帮助。else语句不能有条件,即使有条件,也不会在末尾加分号。请使用此语句
#include<iostream>
using namespace std;
int main()
{
char res[13][6];
int i,j;
int choices=0;
// Declaration of all the variable.
int row0,row1=0,row2=0,row7,row8;
int class_choices=0;
for(i=0;i<13;i++)
for(j=0;j<6;j++)
res[i][j]='*';
do
{
cout<<"Type of service provided. "<<endl;
cout<<"1. To enter your ticket type."<<endl;
cout<<"2. To display full reservation status."<<endl;
cout<<"3. Exit."<<endl<<endl;
cout<<"Enter your choice : ";
cin>>choices;
switch(choices)
{
// Type of class provided.
case 1:
cout<<endl<<"1. First Class"<<endl;
cout<<"2. Economy Class"<<endl;
cout<<"Enter your choice : ";
cin>>class_choices;
switch(class_choices)
{
// First Class.
case 1:
cout<<endl<<"Class specified by you : First Class";
row1=0;
row2=1;
break;
// Economy Class.
case 2:
cout<<endl<<"Class specified by you : Economy Class";
row0;
row1=2;
row2=12;
row7;
row8;
break;
// To indicate the user made a wrong choice.
default:
cout<<"WRONG CHOICE";
break;
}
// To indicate that "*" is available seats and "X" is occupied seats.
cout<<endl<<"* - Available Seats";
cout<<endl<<"X - Occupied Seats";
cout<<endl<<"Available seats for you are :: "<<endl;
cout<<"\t"<<"A B C D E F"<<endl;
for(i=row1;i<=row2;i++)
{
cout<<"Row "<<i+1;
for(j=0;j<6;j++)
{
cout<<"\t"<<res[i][j];
}
cout<<endl;
}
int seat_row;
cout<<endl<<"Enter your desired row : Row ";
cin>>seat_row;
// Condition for the non-smoking section.
if (seat_row>row0 && seat_row<row8)
{
int row0,row8;
cout<<"For your information, these are non-smoking section."<<endl;
}
// Condition for the smoking section.
else (seat_row>row7);
{
int row7;
cout<<"For your information, these are smoking section."<<endl;
}
if(seat_row<(row1+1) || seat_row>(row2+1))
{
cout<<"Invalid row selected";
system("pause");
break;
}
int seat;
cout<<endl<<"Enter your desired seat number (1-6) :";
cin>>seat;
if(seat<1 || seat>6)
{
cout<<"Invalid seat selected";
system("pause");
break;
}
if(res[seat_row-1][seat-1]!='X')
{
res[seat_row-1][seat-1]='X';
cout<<endl<<"Reserved";
}
else
{
cout<<endl<<" Owh,no! ! ! This seat is taken.";
break;
}
system("pause");
break;
// To display reservation status.
case 2:
cout<<endl<<"\tA B C D E F"<<endl;
for(i=0;i<13;i++)
{
cout<<"Row "<<i+1;
for(j=0;j<6;j++)
{
cout<<"\t"<<res[i][j];
}
cout<<endl;
}
system("pause");
// To exit.
case 3:
break;
}
}
while(choices!=3);
return 0;
}
希望这能有所帮助。你说:
...
}
else if(seat_row>row7)
{
...
}
我想你的意思是:
else (seat_row>row7);
{
你说:
...
}
else if(seat_row>row7)
{
...
}
我想你的意思是:
else (seat_row>row7);
{
else(第七排座椅);
应该是
else if(seat_row>row7)
else(seat_row>row7);
应该是
else if(seat_row>row7)
移除else行末尾的;…?:)@razelbe:唯一的飞行方式?更适合于我认为…删除else行末尾的;?:)@razelbe:唯一的飞行方式?更适合于我认为…是的,我现在知道了…所以我使用if&else only…谢谢你的帮助!!是的,我现在知道了…所以我使用if&else only…谢谢你的帮助!!