欢迎来到天天文库
浏览记录
ID:31736389
大小:63.94 KB
页数:15页
时间:2019-01-17
《飞机订票系统c源代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、★include#include#ineludettincludetypedefstructflightnode{charflightnum[10];〃航班号charstart_time[10];//起飞时间charendtime[10];//抵达吋间charstart_place[20];//起飞城市charend_place[20];//抵达城市intleft;//空座数floatprice;//票价floatpricediscount;//票价折扣intisFull;//航班是否满仓struct
2、flightnode*next;//指向下一个结点}flightnode;//航班结点typedefstructpassengernodc{charname[20];//姓名charIDnum[20];//证件号charflight_num[10];//航班号intorder_num;//订单号intticket_num;//订票数量structpassengernode*next;//扌旨向下一个结点}passengernode;//客户结点typedefstructpassengerList{passengcrnode*head;passengernode*rear;}p
3、assengerList;voidinit_flight(flightnode*&h)//FI的是要建立一个以h为头结点的空链表,录入航班信息和增加航班后将航班结点插入该链表{h=(flightnode*)malloc(sizeof(flightnode));//申请头结点的空间if(h==NULL)exit(0);h->next=NULL;//将头结点h的指针域置为空}voidinit_passongerList(passengerList*&pList){pList=(passengerList*)malloc(sizeof(passengerList));phist->
4、hea.d=(passengernode*)mal1oc(sizeof(passengernode));//创建头结点pList->tear二pList->head;pList->rear->order_num=0;//订单号从0开始计数pList->head->next=NULL;voidsavepassenger(passengerList*PList){FILE*fp=fopen("passenger,dat","wb");if(fp==NULL)return;passengernode*temp=PList->head->next;while(temp!=NULL){
5、fwrite(temp,sizeof(passengernode),1,fp);temp=temp->next;};fclose(fp);}void1oadpassenger(passengerList*PList){FILE*fp=fopen("passenger,dat","rb");if(fp=NULL)return;passengernode*q;intn;while(!feof(fp)){q=(passengernode*)nuill()c(sizeof(passengernode));n二fread(q,sizeof(passengernode),1,fp);if
6、(n!=l)break;PList->rear->next=q;PList~>rear=q;}PList->rear->next=NULL;fclose(fp);}voidsaveflight(flightnode*h){FILE*fp=fopen(z,flightList・dat","wb");if(fp=NULL)return;flightnode*temp=h->next;while(temp!=NULL){fwrite(temp,sizeof(flightnode),1,fp);temp=temp->next;};fclose(fp);voidload_f1ight(
7、flightnodc*&h){flightnode*pt二h;FILE*fp=fopen("f1ightList.dat〃,"rb");if(fp=NULL)return;flightnode*q;intn;while(!feof(fp)){(flightnode*)【nalloc(sizoof(flightnodc));n二fredd(q,sizeof(flightnode),1,fp);if(n!=l)break;pt->next=q;pt二q;}pt->next=NULL;fclose(fp);}
此文档下载收益归作者所有