- 1、本文档共10页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
#ifndef _FLIGHT_H_
#define _FLIGHT_H_
#includefstream
using namespace std;
struct node
{
int id;
char start[20];
char over[20];
float s_time;
float o_time;
int price;
float sale;
int ticket;
struct node *next;
};
struct people
{
char name[20];
char passpart[20];
int ticket;
int id;
int number;
struct people *next;
};
class fly
{
public:
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 fly
{
public:
int add();
int insert();
void dele();
int user_id;
};
#endif
#includeiostream
#includeflight.h
#includefstream
using 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航班号 起飞地 目的地 起飞时间 降落时间 票价 折扣 票数endl;
cinp-idp-startp-overp-s_timep-o_timep-pricep-salep-ticket;
while(p!=NULL)
{
cout是否再次输入? 1 是 2 否endl;
cini;
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;
}
else
{
p-next=NULL;
p=p-next;
}
}
n=head;
while(n!=NULL)
{
we.write(reinterpret_castchar*(n),sizeof(struct node));
n=n-next;
}
we.close();
cout录入成功endl;
}
node* fly::read()
{
re.open(flight.txt,ios_base::binary|ios_base::in);
node *h,*s,*p;
h=new node;
p=new node;
p-next=NULL;
re.read(reinterpret_castchar*(p),sizeof(struct node));
h-next=p;
while(!re.eof())
{
s=new node;
re.read(reinterpret_castchar*(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 起飞城市 查找?endl;
cini;
if(i==1)
{
cout请输入航班号endl;
cini;
for(;;)
{
if(p-id==i)
{
cout航班号 p-id 起飞地 p-start 目的地 p-over 起飞时间 p-s_time 降落时间 p-o_time 票价 p-price 折扣 p-sale 票数 p-ticketendl;
return p-ticket;
break;
}
if(p
文档评论(0)