




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
航空客运订票系统源代码#include /dos控制命令头文件#include /输入输出头文件#include /控制格式头文件#include /getchar()用到#include /字符串函数using namespace std;/标准命名空间#define OK 1/函数结果状态码#define ERROR 0/函数结果状态码#define TRUE 1/函数结果状态码#define FALSE 0/函数结果状态码typedef int status;/函数结果状态码static int cusnum=1;/顾客数(全局变量)static int airnum=1;/航线数(全局变量)/顾客结构体struct customer char name9;/ 顾客名 char line_num8;/ 航班号 int piaonum;/ 座位号 struct customer *next;/ 下一个结点 ;typedef customer *Linkcustomer;/候补顾客结构体typedef struct houbuNode/候补顾客结构体char name9;/姓名char end_place10;/终点站int pnum;/票数struct houbuNode *next;/指针域* houbucustomer;struct LinkQueuehoubucustomer front,rear;/队头队尾指针;/航线结构体struct airline char line_num8;/ 航班号 char plane_num8;/ 飞机号 char end_place20;/ 目的的 char fly_data20;/ 飞行周日 int total;/ 座位总数 int left;/ 剩余座位Linkcustomer custom;/ 订票顾客指针LinkQueue houbucus;/ 候补顾客指针 struct airline *next;/ 下一个结点;typedef airline *Linkairline;/初始化航线链表void init_airline(Linkairline &l) l=new airlinesizeof(airline);/产生头结点,并始l指向此头结点 if(!l)/存储分配失败 exit(0);/退出 l-next=NULL;/头结点的指针域为空/初始化顾客链表(同初始化航线链表)void init_customer(Linkcustomer &l) l=new customersizeof(customer); if(!l) exit(0); l-next=NULL;/初始化候补顾客队列链表(同初始化航线链表)void init_houbucustomer(LinkQueue &Q) Q.front=Q.rear=new houbuNodesizeof(houbuNode);/ if(!Q.front) exit(0); Q.front-next=NULL;/判断airline链表是否为空status airLineEmpty(Linkairline L)if(L-next)/非空return FALSE;elsereturn TRUE;/ airline链表插入操作status insert_airline(Linkairline L,int i,char *line_num,char *plane_num,char *end_place, char *fly_data,int total,int left,Linkcustomer custom,LinkQueue houbucus)int j=0;/计数器Linkairline s,p=L;/p指向头结点while(p&jnext;if(!p|ji-1)/i小于1或大于表长return ERROR;/插入失败s=new airlinesizeof(airline);/生成新结点 strcpy(s-line_num , line_num);/给新结点赋值 strcpy(s-plane_num , plane_num); strcpy(s-end_place , end_place); strcpy(s-fly_data , fly_data); s-total =total; s-left =left;s-custom=custom;s-houbucus=houbucus; s-next=p-next;/新结点指向原第i个结点p-next=s;/原第i-1个结点指向新结点 return OK;/插入成功/ customer链表插入操作(同airline链表插入操作)status insert_customer(Linkcustomer L,int i,char *name,char *line_num,int piaonum)int j=0;Linkcustomer s,p=L;while(p&jnext;if(!p|ji-1)return ERROR;s=new customersizeof(customer); strcpy(s-name , name); strcpy(s-line_num , line_num); s-piaonum=piaonum; s-next=p-next;p-next=s; return OK;/ houbucustomer入队操作void insert_houbucustomer(LinkQueue &Q,char *name,char *end_place,int pnum) houbucustomer p; p=new houbuNodesizeof(houbuNode); strcpy(p-name , name); strcpy(p-end_place , end_place); p-pnum=pnum; p-next=NULL;Q.rear-next=p;Q.rear=p;/ houbucustomer出队操作status del_houbucustomer(LinkQueue &Q,houbuNode &hbnode) houbucustomer p;p=Q.front-next;strcpy(,p-name);strcpy(hbnode.end_place,p-end_place);hbnode.pnum=p-pnum;Q.front-next=p-next;if(Q.rear=p)Q.rear=Q.front;delete p;return OK;/houbucustomer输出操作void print_houbucustomer(LinkQueue Q)houbucustomer p=Q.front-next;cout候补顾客为:endl;cout姓名 终点站 票数endl;while(p)coutname end_place pnum;p=p-next;coutendl;/ 打印航线信息status print_airline(Linkairline l) coutendl航班号 飞机号 目的地 飞行周日 总票数 余票数 订票客户 替补客户next ; for(;p!=NULL;p=p-next ) coutsetiosflags(ios:left)setw(9);coutline_numsetw(10)plane_numsetw(9)end_placesetw(12)fly_datasetw(10)totalsetw(8)leftsetw(12)houbucus)setw(10)custom)next; for(;p!=NULL;p=p-next ) if(N=1)info=p-end_place;elseinfo=p-line_num;if(info=name)flag=false;coutendl航班号 飞机号 目的地 飞行周日 总票数 余票数 订票客户 替补客户endl;coutsetiosflags(ios:left)setw(9);/输出格式控制coutline_numsetw(10)plane_numsetw(9)end_placesetw(12)fly_datasetw(10)totalsetw(8)leftsetw(12)custom)setw(10)houbucus)endl;break; if(flag)if(N=1)cout对不起,没有终点站为name的航班endl;elsecout对不起,没有航班号为name的航班next ; for(;p!=NULL;p=p-next ) coutsetiosflags(ios:left);/输出格式控制coutsetw(10)namesetw(12)line_numpiaonumendl; return OK;/航班信息录入status addmoreairline(Linkairline l,Linkcustomer custom,LinkQueue houbucus)char line_num18,plane_num18,fly_data18,end_place18;int total1=100,left1=80;cout请输入以下信息:endlendl;coutline_num1;coutplane_num1;coutend_place1;coutfly_data1;couttotal1;coutleft1;insert_airline(l,airnum,line_num1,plane_num1,end_place1,fly_data1,total1,left1,custom,houbucus);airnum+;cout添加成功!next; for(;p!=NULL;p=p-next ) if(strcmp(line_num,p-line_num )=0) p-left+; return OK; cout没有这个航班,无法完成修改任务!next;/p指向第一个结点 Linkcustomer q=c-next;/q指向第一个结点 for(;p!=NULL;p=p-next)/查找 if(strcmp(end_place,p-end_place )=0) if(p-left-num =0)/剩余票数大于订票数 cout订票成功!line_num,num);/向顾客链表插入记录 p-left-=num;/订票成功,剩余票数减少cusnum+;/顾客数加一 return OK; else/剩余票数小于订票数char pd;cout对不起,余票不足!endl;coutpd;if(pd=Y|pd=y)/需要排队候补insert_houbucustomer(houbu,name,end_place,num);/向候补队列插入记录cout候补登记成功!endl;print_houbucustomer(houbu);else return 0; cout对不起,没有终点站为end_place的航班!next,pr=h;/p指向顾客链表首结点 char line_num8;houbuNode hbnode; while(p!=NULL)/循环查找退票顾客 if(strcmp(name,p-name )=0) strcpy(line_num,p-line_num );for(int i=0;ipiaonum;i+)/更改该航线的剩余票数modefy_airline(l,line_num); pr-next =p-next ; cout顾客name退票成功!next=NULL)elsedel_houbucustomer(houbu,hbnode);/候补顾客出队if(l-next-left=hbnode.pnum)/剩余票数多于排在第一位的客户订的票数/为排在第一位的客户办理订票业务book(l,hbnode.end_place,h,,hbnode.pnum,houbu);cout候补顾客订票成功!endl;else/剩余票数少于排在第一位的客户订的票数coutnext ; p=pr-next ; cout无此顾客,无法退票!endl;/未查到顾客信息 return ERROR;/打开进度条,程序信息简介void open()coutnnnn 课程设计n; coutn -;coutn ;coutn 名称: 航空订票系统 ; coutn ;coutn 作者: 乐升平 ; coutn ;coutn 学号: 201210510216 ; coutn ; coutn 班级:12计科(2)班 ; coutn ; coutn 工具: VC+6.0 C+语言 ; coutn ;coutn -n; system(pause);system(cls);coutnnnnnn *欢迎使用航空订票系统*nnn;const int M=25;int k;cout ;for (k=1;k=M;k+)cout;Sleep(100); system(cls);coutendl【载入完成】aendlendl;cout 前言endlendl;cout 欢迎使用航空订票系统,本程序实现了以下功能:nn;cout 录入功能:可以录入航班情况nn;cout 查询功能:根据客户提供的终点站名或航班号进行查询。nn;cout 订票功能:根据客户提出的要求及实际情况为客户办理订票手续,且跟据需要nn;cout 可登记排队候补。nn;cout 退票功能:根据客户提供的情况为客户办理退票手续,若有候补订票顾客还可nn;cout 为排在第一位的客户办理订票手续。nn;system(pause);system(cls); /主函数int main()open(); char choice,name9,end_place10;int t=1,num;Linkairline air;Linkcustomer customer;LinkQueue houbu; init_airline(air);/初始化airline链表 init_customer(customer);/初始化customer链表init_houbucustomer(houbu);/初始化houbucustomer队列 while(t=1)/进入菜单 system(cls); coutnn *欢迎使用航空订票系统*nn;cout 请选择菜单nn;cout 1 录入nn; cout 2 订票nn; cout 3 退票nn; cout 4 查询nn; cout 0 退出nn; coutchoice; switch(choice)case 1:/航班信息录入system(cls);addmoreairline(air,customer,houbu);/录入航班信息system(pause);break;case 2:/订票system(cls);if(airLineEmpty(air)/订票前航班信息为空coutERROR!请先输入航线信息!endl;elsecoutend_place;coutname;coutnum;book(air,end_place,customer,name,num,houbu);/办理订票业务system(pause);break;case 3:/退票system(cls); coutendlname; delete_cus(customer,air,name,houbu);/办理退票业务system(pause); break;case 4:/查询航班及订票信息system(cls);if(airLineEmp
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 离婚协议中子女抚养权变更及监护权调整细节合同
- 科研实验室租赁合同担保与科研成果转化协议
- 精装修二手房买卖合同含家具家电拆装及搬运服务
- 电子合同在电子合同电子合同监管中的法律问题及对策
- 茶文化体验馆门面房屋租赁及茶艺培训合同
- 文化创意产业知识产权授权与软件开发合同
- 深入分析2025年公路货运行业数字化转型与效率提升的物流行业创新案例分析报告
- 2025年外科护理试卷模拟及答案
- 农村地区新能源技术创新与扶贫模式研究报告
- 2025年中国高端户外夹克行业市场全景分析及前景机遇研判报告
- 跨境电商第三方物流合作中的三方保密协议及责任划分
- 网信专员考试题及答案
- 2019ESCEAS血脂异常管理指南2025重点更新解读
- 《现代传感与检测技术》教学大纲
- 挖煤专业毕业论文
- 山路车辆行车安全培训课件
- 2025北京京剧院招聘工作人员10人笔试备考题库及答案解析
- 转基因玉米培训课件
- 建筑设计公司结构设计师工作手册
- 2025年青海省事业单位招聘考试卫生类护理学专业知识试题
- 宝宝呛奶科普课件
评论
0/150
提交评论