#include <stdio.h>
static int NOSmoke=0;
static int Smoke=0;
int FunSmoke()
{
if (Smoke<3)//
{
Smoke++;
return Smoke;
}
}
int FunNoSmoke()
{
if (NOSmoke<7)//
{
NOSmoke++;
return NOSmoke;
}
}
void out_count()
{
printf("有烟区还有余票%d张\n",3-Smoke);
printf("无烟区还有余票%d张\n",7-NOSmoke);
}
int main()
{
int select=5;
out_count();
while (1)
{
int select_two=0;
int select_three=0;
static int flag=0;
printf("\t\t选择有烟区还是无烟区\n\t\t0退出\n\t\t1有烟区\n\t\t2无烟区\n");
printf("请选择:");
scanf("%d",&select);
fflush(stdin);
switch (select)
{
case 1:
{
if (Smoke<3)//
{
printf("你已经成功预订有烟区的座位号是:%d\n",FunSmoke());
printf("\n\n\n");
}
if ((Smoke==3)&&(NOSmoke!=7))//
{
printf("\n\n\n有烟区票已售完\n");
printf("无烟区还有余票%d张\n",7-NOSmoke);
printf("\t\t选择无烟区吗?\n\t\t0返回上一层\n\t\t1选择\n");
printf("请选择:");
scanf("%d",&select_two);
fflush(stdin);;
switch (select_two)
{
case 1:
{
printf("你已经成功预订无烟区的座位号是:%d\n",FunNoSmoke());
printf("\n\n\n");
break;
}
default:
break;
}
}
if ((Smoke==3)&&NOSmoke==7)//
{
printf("\t\t\t\t\t\t所有的票已经售完输入0退出:");
scanf("%d",&select);
fflush(stdin);
}
break;
}
case 2:
{
if (NOSmoke<7)//
{
printf("你已经成功预订无烟区的座位号是:%d\n",FunNoSmoke());
printf("\n\n\n");
break;
}
else
{
if (Smoke<3)
{
printf("\n\n\n无烟区票已售完\n");
printf("有烟区还有余票%d张\n",3-Smoke);
printf("\t\t选择有烟区吗?\n\t\t0返回上一层\n\t\t1选择\n");
scanf("%d",&select_three);
fflush(stdin);
switch (select_three)
{
case 1:
{
printf("你已经成功预订有烟区的座位号是:%d\n",FunSmoke());
printf("\n\n\n");
break;
}
default:
break;
}
}
if ((Smoke==3)&&NOSmoke==7)//
{
printf("\t\t\t\t\t\t所有的票已经售完,输入0退出:");
scanf("%d",&select);
fflush(stdin);
}
}
break;
}
default:
break;
}
if (select==0)
{
break;
}
}
return 0;
}