⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test05.cpp

📁 数组、指针和引用的操作练习 航空售票系统:为一个容量为10个座位飞机的航班之每次飞行分配座位。程序显示两个选项的菜单: please type 1 for ″smoking″ please
💻 CPP
字号:
// test05.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
using namespace std;

int main(int argc, char* argv[])
{
	int i,j,k,m,p,num,a[5],b[5];
	char c;
	for(i=0;i<5;i++)
	{
		a[i]=0;
		b[i]=0;
	}
	for(j=0;j<=10;j++)
	{
		cout<<"please type 1 for \"smoking\""<<"\n";
		cout<<"please type 2 for \"nonsmoking\""<<"\n";
		cin>>num;
		if(num==1)
		{
        	for(k=0;k<5;k++)
			{
				if(a[k]==0)
				{
					a[k]=1;
					cout<<"your number is:  "<<k+1<<"\n";
					cout<<"you are in \"smoking\""<<"\n"<<"\n";
					break;
				}
				if(a[4]==1)
				{
					cout<<"there is no seat in \"smoking\""<<"\n";
					cout<<"if you want \"nonsmoking\",please type \'y\';otherwise type \'n\'"<<"\n";
					cin>>c;
					if(c=='y')
					{
						for(m=0;m<5;m++)
						{
							if(b[m]==0)
							{
								b[m]=1;
                                cout<<"your number is:  "<<m+6<<"\n";
					            cout<<"you are in \"nonsmoking\""<<"\n"<<"\n";
								break;
							}
							if(b[4]==1)
							{
								cout<<"there is no seat for you"<<"\n"<<"\n";
			
							}
						}
					}
					else
					{
						cout<<"Next flight leaves 6 hour."<<"\n"<<"\n";
					}
					break;
				}
				
			}
				
		}
		if(num==2)
		{
			for(p=0;p<6;p++)
			{
				if(b[p]==0)
				{
					b[p]=1;
					cout<<"your number is   "<<p+6<<"\n";
					cout<<"you are in \"nonsmoking\""<<"\n"<<"\n";
					break;
				}
			   if(b[4]==1)
				{
					cout<<"there is no seat for you "<<"\n"<<"\n";
				    break;
				}
				
			}
		}
		
	}
		

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -