#include
#include
#define LEN 20
#define ROW 20
using namespace std;
void initseat(char s[LEN][ROW])
{
int i,j;
for(i=0;i {
for(j=0;j {
s[i][j]=' ';
}
}
}
void printmenu()
{
cout<<"\t\t1.查询座位\t"<<"2.预定座位"< cout<<"\t\t3.打印电影票\t"<<"4.显示所有位置"< cout<<"\t\t0.退出"<}
void printseat(char s[LEN][ROW])
{
int i,j;
cout<<" ";
for(i=0;i cout< cout< for(i=0;i {
cout< for(j=0;j cout< cout< }
}
bool searchfull(char s[LEN][ROW])
{
int l,r;
cout<<"您要查找的行数为:";
cin>>l;
cout<<"您要查找的列数为:";
cin>>r;
if(s[l-1][r-1]!=' ')
{
cout<<"您查找的座位已有人!!!"< return false;
}
else
{
cout<<"您查找的座位没有人!!!"< return true;
}
}
bool printticket(char s[LEN][ROW],int l,int r)
{
cout<<"电影名称:"<<"星际穿越"< cout<<"座位:"< cout<<"放映时间:"<<"2014年12月20日14:00"< return true;
}
bool reservation(char s[LEN][ROW])
{
int l,r;
cout<<"您要预定的行数为:";
cin>>l;
cout<<"您要预定的列数为:";
cin>>r;
if(!(l<=LEN&&l>=0&&r<=ROW&&r>=0))
{
cout<<"您的输入不合法!!!"< return false;
}
bool flag;
if(s[l-1][r-1]=='#')
flag=false;
else
flag=true;
if(flag==false)
{
cout<<"此座位已有人!!!"< return false;
}
s[l-1][r-1]='#';
printticket(s,l,r);
return true;
}
int main()
{
char seat[LEN][ROW];
int flag,l,r;
initseat(seat);
printseat(seat);
printmenu();
while(cin>>flag,flag!=0)
{
switch(flag)
{
case 1:searchfull(seat);break;
case 2:reservation(seat);break;
case 3:cout<<"请输入您要打印的行数:";cin>>l;
cout<<"请输入您要打印的行数:";cin>>r;
if(!(l<=LEN&&l>=0&&r<=ROW&&r>=0))
{
cout<<"您的输入不合法!!!"< break;
}
printticket(seat,l,r);
break;
case 4:printseat(seat);
default:break;
}
printmenu();
}
return 0;
}