#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;
}我的错误是错误C2143:语法错误:缺少';‘位于以下位置的'{’之前: else (seat_row>row7);{ int row7;cout<<“供您参考,这些是冒烟部分<
发布于 2011-04-13 18:38:19
else语句不能有条件,即使有,也不会在语句的末尾加分号。使用这个
...
}
else if(seat_row>row7)
{
    ...
}希望这能有所帮助。
发布于 2011-04-13 18:38:46
你说过:
else  (seat_row>row7);
    {我想你的意思是:
else if (seat_row > row7)
    {发布于 2011-04-13 18:39:08
else  (seat_row>row7);
应该是
else if (seat_row>row7)
https://stackoverflow.com/questions/5647744
复制相似问题