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

上传人:b****6 文档编号:7043687 上传时间:2023-01-16 格式:DOCX 页数:13 大小:16.29KB
下载 相关 举报
C++版大大数据结构航空订票系统源代码.docx_第1页
第1页 / 共13页
C++版大大数据结构航空订票系统源代码.docx_第2页
第2页 / 共13页
C++版大大数据结构航空订票系统源代码.docx_第3页
第3页 / 共13页
C++版大大数据结构航空订票系统源代码.docx_第4页
第4页 / 共13页
C++版大大数据结构航空订票系统源代码.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

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

《C++版大大数据结构航空订票系统源代码.docx》由会员分享,可在线阅读,更多相关《C++版大大数据结构航空订票系统源代码.docx(13页珍藏版)》请在冰豆网上搜索。

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

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

#ifndef_FLIGHT_H_

#define_FLIGHT_H_

#include

usingnamespacestd;

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;

};

classfly

{

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"

usingnamespacestd;

voidfly:

:

add()

{

inti;

node*p=newnode;

node*s,*n;

head=p;

we.open("flight.txt",ios_base:

:

app|ios_base:

:

binary);

cout<<"请依次输入航班信息:

"<

cout<<"航班号起飞地目的地起飞时间降落时间票价折扣票数"<

cin>>p->id>>p->start>>p->over>>p->s_time>>p->o_time>>p->price>>p->sale>>p->ticket;

while(p!

=NULL)

{

cout<<"是否再次输入?

1是2否"<

cin>>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();

cout<<"录入成功"<

}

node*fly:

:

read()

{

re.open("flight.txt",ios_base:

:

binary|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(structnode));

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起飞城市查找?

"<

cin>>i;

if(i==1)

{

cout<<"请输入航班号"<

cin>>i;

for(;;)

{

if(p->id==i)

{

cout<<"航班号"<id<<"起飞地"<start<<"目的地"<over<<"起飞时间"<s_time<<"降落时间"<o_time<<"票价"<price<<"折扣"<sale<<"票数"<ticket<

returnp->ticket;

break;

}

if(p->next==NULL)

{

cout<<"查无次航班信息"<

break;

}

p=p->next;

}

i=0;

}

if(i==2)

{

charove[20];

cout<<"请输入抵达城市"<

cin>>ove;

for(;;)

{

if(strcmp(p->over,ove)==0)

{

cout<<"航班号"<id<<"起飞地"<start<<"目的地"<over<<"起飞时间"<s_time<<"降落时间"<o_time<<"票价"<price<<"折扣"<sale<<"票数"<ticket<

return-1;

}

if(p->next==NULL)

{

break;

}

p=p->next;

}

}

if(i==3)

{

charsta[20];

cout<<"请输入起飞城市"<

cin>>sta;

for(;;)

{

if(strcmp(p->start,sta)==0)

{

cout<<"航班号"<id<<"起飞地"<start<<"目的地"<over<<"起飞时间"<s_time<<"降落时间"<o_time<<"票价"<price<<"折扣"<sale<<"票数"<ticket<

return-1;

}

if(p->next==NULL)

{

break;

}

p=p->next;

}

}

}

 

voidfly:

:

update()

{

inti;

node*p,*n,*h;

h=read();

p=h->next;

cout<<"请输入您要修改的航班信息的航班号"<

cin>>i;

for(;;)

{

if(p->id==i)

{

cout<<"航班号"<id<<"起飞地"<start<<"目的地"<over<<"起飞时间"<s_time<<"降落时间"<o_time<<"票价"<price<<"折扣"<sale<<"票数"<ticket<

cout<<"请输入修改后的航班信息:

"<

cout<<"航班号起飞地目的地起飞时间降落时间票价折扣票数"<

cin>>p->id>>p->start>>p->over>>p->s_time>>p->o_time>>p->price>>p->sale>>p->ticket;

break;

}

if(p->next==NULL)

{

cout<<"查无此航班信息"<

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(structnode));

n=n->next;

}

we.close();

cout<<"修改成功"<

 

}

voidfly:

:

update_ticket(intid,intu_id)

{

node*p,*n,*h;

h=read();

p=h->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(structnode));

n=n->next;

}

we.close();

}

 

intuser:

:

add()

{

people*p=newpeople;

we.open("user.txt",ios_base:

:

app|ios_base:

:

binary);

cout<<"请依次输入订票信息:

"<

cout<<"客户姓名证件号订票数量航班号订单编号"<

cin>>p->name>>p->passpart>>p->ticket>>p->id>>p->number;

we.write(reinterpret_cast(p),sizeof(structpeople));

we.close();

user_id=p->id;

cout<<"录入成功"<

returnp->ticket;

}

intuser:

:

insert()

{

intticket,id;

ticket=select();

if(ticket==-1)

{

cout<<"请再次查询确定航班号"<

}

else

{

if(ticket==0)

cout<<"该航班无票"<

else

{

id=add();

returnid;

}

}

 

}

voiduser:

:

dele()

{

intnum;

re.open("user.txt",ios_base:

:

binary|ios_base:

:

in);

people*h,*s,*p,*n,*m;

h=newpeople;

p=newpeople;

re.read(reinterpret_cast(p),sizeof(structpeople));

h->next=p;

while(!

re.eof())

{

s=newpeople;

re.read(reinterpret_cast(s),sizeof(structpeople));

p->next=s;

p=s;

p->next=NULL;

}

re.close();

cout<<"请输入您要删除的客户订单编号"<

cin>>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(structpeople));

p=p->next;

}

we.close();

cout<<"删除成功"<

break;

}

n=n->next;

m=m->next;

}

 

}

#include"iostream"

#include"flight.h"

#include"fstream"

usingnamespacestd;

intmain()

{

usera;

flyb;

inti,s,id;

cout<<"欢迎进入航班订票系统"<

cout<<"请选择:

"<

cout<<"1航班信息管理2订票信息管理3退出"<

cout<<"请选择您要实施的操作;"<

cin>>i;

system("CLS");

switch(i)

{

case1:

cout<<"1添加航班信息2查找航班信息3修改航班信息4返回上一层"<

cin>>s;

system("CLS");

switch(s)

{

case1:

b.add();

break;

case2:

a.select();

break;

case3:

a.update();

break;

default:

system("CLS");

}

break;

case2:

cout<<"1添加订票信息2删除订票信息3返回上一层"<

cin>>s;

system("CLS");

switch(s)

{

case1:

id=a.insert();

a.update_ticket(id,a.user_id);

break;

case2:

a.dele();

break;

case3:

break;

}

break;

case3:

return0;

break;

}

 

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1