C++版数据结构航空订票系统源代码.doc
#ifndef _FLIGHT_H_#define _FLIGHT_H_#includeusing 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#include"iostream"#include"flight.h"#include"fstream"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<>p->id>>p->start>>p->over>>p->s_time>>p->o_time>>p->price>>p->sale>>p->ticket;while(p!=NULL){cout<>i;if(i==1){s=new node;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(struct node));n=n->next;}we.close();cout<
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_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<>i;if(i==1){cout<>i;for(;;){if(p->id==i){cout<id<sta