#include
#include
const int MAXNUM = 28;
using namespace std;
int main()
{
char a[7][5] = {{1,'A','B','C','D'},{2,'A','B','C','D'},{3,' A','B','C','D} ,{4,'A','B','C','D'},{5,'A','B','C','D'},{6,'A','B','C','D'},{7,'A','B','C','D'}};
int num = 0;
int index;
char pos;
while( num < MAXNUM )
{
cout << "请输入座位号(数字 字母): ";
cin >> index >> pos;
if ( (index < 1 || index > 7) ||
(pos < 'A' || pos > 'D'))
{
cout << "请输入正确的座位信息!" << endl;
continue;
}
if ( a[index-1][(int)(pos-'A') + 1] == 'X')
{
cout << "座位已被预定,请重新选择!" << endl;
continue;
}
else
{
cout << "座位预定成功!" << endl;
a[index-1][(int)(pos-'A')+1] = 'X';
num++;
}
}
system("pause");
return 0;
}
VS2008下调试通过,结果正确,简单明了=.=,望采纳~