航班编程代码c语言,航班查询系统C语言源程序

《航班查询系统C语言源程序》由会员分享,可在线阅读,更多相关《航班查询系统C语言源程序(8页珍藏版)》请在人人文库网上搜索。

1、include #include #include #define NOD struct plane_liststruct planechar number 10;char start10;char arrive 10;char date10;char starttime10;char arrivingtime10;char price10;char model10;NODchar number 10;char start10;char arrive 10;char date10;char starttime10;char arrivingtime10;char price10;char mo。

2、del10;NOD*next;FILE *fp;/*由文件中的数据生成一个飞机航班的链表,如果文件不存在,则是一个空链表*/NOD *load(char planename) NOD *p,*q,*head;struct plane per;p=(NOD *)malloc(sizeof(NOD);q=head=NULL;if(fp=fopen(planename,rb)=NULL)return head;else while(!feof(fp) if(fread(&per,sizeof(struct plane),1,fp)=1)p=(NOD *)malloc(sizeof(NOD);strc。

3、py(p-number,per.number);strcpy(p-start,per.start);strcpy(p-arrive,per.arrive);strcpy(p-date,per.date);strcpy(p-starttime,per.starttime);strcpy(p-arrivingtime,per.arrivingtime);strcpy(p-price,per.price);strcpy(p-model,per.model);head=p;p-next=q;q=head;fclose(fp);return(head);/*输入*/NOD *insert(NOD *he。

4、ad) NOD *temp,*p;p=head;temp=(NOD *)malloc(sizeof(NOD);printf(nt请输入航班号:);scanf(%s,temp-number);printf(nt请输入起点站:);scanf(%s,temp-start);printf(nt请输入终点站:);scanf(%s,temp-arrive);printf(nt请输入起飞时间:);scanf(%s,temp-starttime);printf(nt请输入到达时间:);scanf(%s,temp-arrivingtime);printf(nt请输入班期:);scanf(%s,temp-date。

5、);printf(nt请输入票价:);scanf(%s,temp-price);printf(nt请输入航班型号:);scanf(%s,temp-model);head=temp;temp-next=p;return head;/*保存*/void save(NOD *head, char filename)NOD*p;struct plane per;if(fp=fopen(filename,wb)=NULL)printf( 文件无法写入);exit(0);else p=head;while(p!=NULL) strcpy(per.number,p-number);strcpy(per.st。

6、art,p-start);strcpy(per.arrive,p-arrive);strcpy(per.date,p-date);strcpy(per.starttime,p-starttime);strcpy(per.arrivingtime,p-arrivingtime);strcpy(per.price,p-price);strcpy(per.model,p-model);if(fwrite(&per,sizeof(struct plane),1,fp)!=1)printf(文件不能写入数据,请检查后重新运行.n);exit(0);p=p-next;fclose(fp);/*显示*/vo。

7、id display(NOD *head) NOD *p;p=head;while(p!=NULL) printf(航班号:%sn,p-number);printf(起点站:%sn,p-start);printf(终点站:%sn,p-arrive);printf(班期:%sn,p-date);printf(起飞时间:%sn,p-starttime);printf(到达时间:%sn,p-arrivingtime);printf(票价:%sn,p-price);printf(飞机型号:%sn,p-model);p=p-next;/*航班号查找*/void finda(NOD *head) NOD 。

8、*p;char number10;printf(请输入查找航班的编号:);scanf(%s,number);p=head;while (p!=NULL) if(strcmp(number,p-number)=0) printf(航班号:%sn,p-number);printf(起点站:%sn,p-start);printf(终点站:%sn,p-arrive);printf(班期:%sn,p-date);printf(起飞时间:%sn,p-starttime);printf(到达时间:%sn,p-arrivingtime);printf(票价:%sn,p-price);printf(飞机型号:%。

9、sn,p-model);break;elsep=p-next;if(p=NULL)printf(nt查无此航班n);/*起点站查找*/void findb(NOD *head) NOD *p;char start10;printf(请输入查找航班的起点站:);scanf(%s,start);p=head;while (p!=NULL) if(strcmp(start,p-start)=0) printf(航班号:%sn,p-number);printf(起点站:%sn,p-start);printf(终点站:%sn,p-arrive);printf(班期:%sn,p-date);printf(。

10、起飞时间:%sn,p-starttime);printf(到达时间:%sn,p-arrivingtime);printf(票价:%sn,p-price);printf(飞机型号:%sn,p-model);break;elsep=p-next;if(p=NULL)printf(nt查无此航班n);/*终点站查找*/void findc(NOD *head) NOD *p;char arrive10;printf(请输入查找航班的终点站:);scanf(%s,arrive);p=head;while (p!=NULL) if(strcmp(arrive,p-arrive)=0) printf(航班。

11、号:%sn,p-number);printf(起点站:%sn,p-start);printf(终点站:%sn,p-arrive);printf(班期:%sn,p-date);printf(起飞时间:%sn,p-starttime);printf(到达时间:%sn,p-arrivingtime);printf(票价:%sn,p-price);printf(飞机型号:%sn,p-model);break;elsep=p-next;if(p=NULL)printf(nt查无此航班n);/*起飞时间查找*/void findd(NOD *head) NOD *p;char starttime10;pr。

12、intf(请输入查找航班的起飞时间:);scanf(%s,starttime);p=head;while (p!=NULL) if(strcmp(starttime,p-starttime)=0) printf(航班号:%sn,p-number);printf(起点站:%sn,p-start);printf(终点站:%sn,p-arrive);printf(班期:%sn,p-date);printf(起飞时间:%sn,p-starttime);printf(到达时间:%sn,p-arrivingtime);printf(票价:%sn,p-price);printf(飞机型号:%sn,p-mod。

13、el);break;elsep=p-next;if(p=NULL)printf(nt查无此航班n);/*到达时间查找*/void finde(NOD *head) NOD *p;char arrivingtime10;printf(请输入查找航班的到达时间:);scanf(%s,arrivingtime);p=head;while (p!=NULL) if(strcmp(arrivingtime,p-arrivingtime)=0) printf(航班号:%sn,p-number);printf(起点站:%sn,p-start);printf(终点站:%sn,p-arrive);printf(。

14、班期:%sn,p-date);printf(起飞时间:%sn,p-starttime);printf(到达时间:%sn,p-arrivingtime);printf(票价:%sn,p-price);printf(飞机型号:%sn,p-model);break;elsep=p-next;if(p=NULL)printf(nt查无此航班n);/*删除*/NOD *dele(NOD *head) NOD *p,*q;char number5;printf(:请输入要删除的航班编号);scanf(%s,number);p=q=head;while(p!=NULL) if(strcmp(number,p。

15、-number)=0)if(head=p)head=p-next;else q-next=p-next;free(p);break;elseq=p;p=p-next;if(p=NULL)printf(nt查无此航班n);return head;/*主函数*/void main() NOD *head;char fnum10;int choise;printf(nt欢迎光临航班查询系统:);scanf(%s,fnum);head=load(fnum);while(1) printf(ntt 航班信息检索与查询n);printf(tt*n);printf(tt 1.航班号查找n);printf(t。

16、t 2.起点站查找n);printf(tt 3.终点站查找n);printf(tt 4.起飞时间查找n);printf(tt 5.到达时间查找n);printf(tt 6.航班号删除n);printf(tt 7.增加新航班n);printf(tt 8.显示所有航班n);printf(tt 9.存盘并退出n);printf(nt请选择1-9:);scanf(%d,&choise);switch(choise) case 1:finda(head);break;case 2:findb(head);break;case 3:findc(head);break;case 4:findd(head);break;case 5:finde(head);break;case 6:head=dele(head);break;case 7:head=insert(head);break;case 8:display(head);break;case 9:save(head,fnum); exit(0);default:printf(输入错误,重新输入n);。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值