C++版数据结构航空订票系统源代码

上传人:1888****888 文档编号:36272429 上传时间:2021-10-30 格式:DOC 页数:10 大小:15.81KB
返回 下载 相关 举报
C++版数据结构航空订票系统源代码_第1页
第1页 / 共10页
C++版数据结构航空订票系统源代码_第2页
第2页 / 共10页
C++版数据结构航空订票系统源代码_第3页
第3页 / 共10页
点击查看更多>>
资源描述
#ifndef _FLIGHT_H_#define _FLIGHT_H_#includeusing namespace std;struct nodeint id;char start20;char over20;float s_time;float o_time;int price;float sale;int ticket;struct node *next;struct peoplechar name20;char passpart20;int ticket;int id;int number;struct people *next;class flypublic:void add();node* read();int select();void update();void update_ticket(int id,int u_id);ofstream we;ifstream re;private:node *head;class user:public flypublic:int add();int insert();void dele();int user_id;#endif#includeiostream#includeflight.h#includefstreamusing namespace std;void fly:add()int i;node *p=new node;node *s,*n;head=p;we.open(flight.txt,ios_base:app|ios_base:binary);cout请依次输入航班信息:endl;cout航班号 起飞地 目的地 起飞时间 降落时间 票价 折扣 票数p-idp-startp-overp-s_timep-o_timep-pricep-salep-ticket;while(p!=NULL)cout是否再次输入? 1 是 2 否i;if(i=1)s=new node;cins-ids-starts-overs-s_times-o_times-prices-sales-ticket;p-next=s;p=s;p-next=NULL;elsep-next=NULL;p=p-next;n=head;while(n!=NULL)we.write(reinterpret_cast(n),sizeof(struct node);n=n-next;we.close();cout录入成功next=NULL;re.read(reinterpret_cast(p),sizeof(struct node);h-next=p;while(!re.eof()s=new node;re.read(reinterpret_cast(s),sizeof(struct node);p-next=s;p=s;p-next=NULL;re.close();return h;int fly:select()node *p,*h;h=read();p=h-next;int i;cout您是要按 1 航班号 2 抵达城市 3 起飞城市 查找?i;if(i=1)cout请输入航班号i;for(;)if(p-id=i)cout航班号 id 起飞地 start 目的地 over 起飞时间 s_time 降落时间 o_time 票价 price 折扣 sale 票数 ticketticket;break;if(p-next=NULL)cout查无次航班信息next;i=0;if(i=2)char ove20;cout请输入抵达城市ove;for(;)if(strcmp(p-over,ove)=0)cout航班号 id 起飞地 start 目的地 over 起飞时间 s_time 降落时间 o_time 票价 price 折扣 sale 票数 ticketnext=NULL)break;p=p-next;if(i=3)char sta20;cout请输入起飞城市sta;for(;)if(strcmp(p-start,sta)=0)cout航班号 id 起飞地 start 目的地 over 起飞时间 s_time 降落时间 o_time 票价 price 折扣 sale 票数 ticketnext=NULL)break;p=p-next;void fly:update()int i;node *p,*n,*h;h=read();p=h-next;cout请输入您要修改的航班信息的航班号i;for(;)if(p-id=i)cout航班号 id 起飞地 start 目的地 over 起飞时间 s_time 降落时间 o_time 票价 price 折扣 sale 票数 ticketendl;cout请输入修改后的航班信息:endl;cout航班号 起飞地 目的地 起飞时间 降落时间 票价 折扣 票数p-idp-startp-overp-s_timep-o_timep-pricep-salep-ticket;break;if(p-next=NULL)cout查无此航班信息next;n=h-next;we.open(flight.txt,ios_base:trunc|ios_base:binary);while(n!=NULL)we.write(reinterpret_cast(n),sizeof(struct node);n=n-next;we.close();cout修改成功next;for(;)if(p-id=u_id)p-ticket=p-ticket-id;break;if(p-next=NULL)break;p=p-next;n=h-next;we.open(flight.txt,ios_base:trunc|ios_base:binary);while(n!=NULL)we.write(reinterpret_cast(n),sizeof(struct node);n=n-next;we.close();int user:add()people *p=new people;we.open(user.txt,ios_base:app|ios_base:binary);cout请依次输入订票信息:endl;cout客户姓名 证件号 订票数量 航班号 订单编号p-namep-passpartp-ticketp-idp-number;we.write(reinterpret_cast(p),sizeof(struct people);we.close();user_id=p-id;cout录入成功ticket;int user:insert()int ticket,id;ticket=select();if(ticket=-1)cout请再次查询确定航班号endl;elseif(ticket=0)cout该航班无票endl;elseid=add();return id;void user:dele()int num;re.open(user.txt,ios_base:binary|ios_base:in);people *h,*s,*p,*n,*m;h=new people;p=new people;re.read(reinterpret_cast(p),sizeof(struct people);h-next=p;while(!re.eof()s=new people;re.read(reinterpret_cast(s),sizeof(struct people);p-next=s;p=s;p-next=NULL;re.close();cout请输入您要删除的客户订单编号num;m=h;n=h-next;while(n!=NULL)if(n-number=num)m-next=n-next;p=h-next; we.open(user.txt,ios_base:binary); while(p!=NULL) we.write(reinterpret_cast(p),sizeof(struct people); p=p-next; we.close(); cout删除成功next;m=m-next;#includeiostream#includeflight.h#includefstreamusing namespace std;int main()user a;fly b;int i,s,id;cout 欢迎进入航班订票系统endl;cout请选择:endl;cout1 航班信息管理 2 订票信息管理 3 退出endl;cout请选择您要实施的操作;i;system(CLS);switch(i)case 1:cout1 添加航班信息 2 查找航班信息 3 修改航班信息 4 返回上一层s;system(CLS);switch(s)case 1:b.add();break;case 2:a.select();break;case 3:a.update();break;default:system(CLS);break;case 2:cout1 添加订票信息 2 删除订票信息 3 返回上一层s;system(CLS);switch(s)case 1:id=a.insert();a.update_ticket(id,a.user_id);break;case 2:a.dele();break;case 3:break;break;case 3:return 0;break;
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸设计 > 任务书类


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!