欢迎来到天天文库
浏览记录
ID:17047227
大小:15.95 KB
页数:10页
时间:2018-08-27
《c++版数据结构航空订票系统源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#ifndef_FLIGHT_H_#define_FLIGHT_H_#includeusingnamespacestd;structnode{intid;charstart[20];charover[20];floats_time;floato_time;intprice;floatsale;intticket;structnode*next;};structpeople{charname[20];charpasspart[20];intticket;intid;intnumber;structpeople*next;};classf
2、ly{public:voidadd();node*read();intselect();voidupdate();voidupdate_ticket(intid,intu_id);ofstreamwe;ifstreamre;private:node*head;};classuser:publicfly{public:intadd();intinsert();voiddele();intuser_id;};#endif#include"iostream"#include"flight.h"#include"fstream"usingnamespacest
3、d;voidfly::add(){inti;node*p=newnode;node*s,*n;head=p;we.open("flight.txt",ios_base::app
4、ios_base::binary);cout<<"请依次输入航班信息:"<>p->id>>p->start>>p->over>>p->s_time>>p->o_time>>p->price>>p->sale>>p->ticket;while(p!=NULL){cout<<"是否再次输
5、入?1是2否"<>i;if(i==1){s=newnode;cin>>s->id>>s->start>>s->over>>s->s_time>>s->o_time>>s->price>>s->sale>>s->ticket;p->next=s;p=s;p->next=NULL;}else{p->next=NULL;p=p->next;}}n=head;while(n!=NULL){we.write(reinterpret_cast(n),sizeof(structnode));n=n->next;}we.close()
6、;cout<<"录入成功"<7、ios_base::in);node*h,*s,*p;h=newnode;p=newnode;p->next=NULL;re.read(reinterpret_cast(p),sizeof(structnode));h->next=p;while(!re.eof()){s=newnode;re.read(reinterpret_cast(s),sizeof(structnod8、e));p->next=s;p=s;p->next=NULL;}re.close();returnh;}intfly::select(){node*p,*h;h=read();p=h->next;inti;cout<<"您是要按1航班号2抵达城市3起飞城市查找?"<>i;if(i==1){cout<<"请输入航班号"<>i;for(;;){if(p->id==i){cout<<"航班号"<id<<"起飞地"<start<<"目的地"<over<<"起飞时间"<s_time<<"降落9、时间"<o_time<<"票价"<price<<"折扣"<sale<<"票数"<ticket<ticket;break;}if(p->next==NULL){cout<<"查无次航班信息"<next;}i=0;}if(i==2){charove[20];cout<<"请输入抵达城市"<>ove;for(;;){if(strcmp(p->over,ove)==0){cout<<"航班号"<id<<"起飞地"<start<<10、"目的地"<over<<"起飞时间"<s_time<<"降落时间"<o
7、ios_base::in);node*h,*s,*p;h=newnode;p=newnode;p->next=NULL;re.read(reinterpret_cast(p),sizeof(structnode));h->next=p;while(!re.eof()){s=newnode;re.read(reinterpret_cast(s),sizeof(structnod
8、e));p->next=s;p=s;p->next=NULL;}re.close();returnh;}intfly::select(){node*p,*h;h=read();p=h->next;inti;cout<<"您是要按1航班号2抵达城市3起飞城市查找?"<>i;if(i==1){cout<<"请输入航班号"<>i;for(;;){if(p->id==i){cout<<"航班号"<id<<"起飞地"<start<<"目的地"<over<<"起飞时间"<s_time<<"降落
9、时间"<o_time<<"票价"<price<<"折扣"<sale<<"票数"<ticket<ticket;break;}if(p->next==NULL){cout<<"查无次航班信息"<next;}i=0;}if(i==2){charove[20];cout<<"请输入抵达城市"<>ove;for(;;){if(strcmp(p->over,ove)==0){cout<<"航班号"<id<<"起飞地"<start<<
10、"目的地"<over<<"起飞时间"<s_time<<"降落时间"<o
此文档下载收益归作者所有