资源描述:
《C语言程序设计——飞机订票系统》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C语言程序设计——飞机订票系统代码如下:”#include"stdio.h"#include"stdlib.h"#include"string.h"#defineLENsizeof(structplane)#defineMAX10;structplane{chardestination[12];charnum[10];chartime[12];intprice;intamount;};typedefstructplanePLANE;PLANEa[100];voidmenu();voidinput();voids
2、earch();voidpreserve();voidplaneadd();voiddelplane();voidmain(){system("cls");menu();}voidmenu(){charmenu[]={欢迎进入飞机订票系统,"a:输入航线","b:查询航线","c:退订票系统","d:追加航线","e:删除航线","f:退出",""};inti;charNO;intquit=0;do{system("cls");for(i=0;i<9;i++)printf("%s",menu[i]);pri
3、ntf("请输入服务代码a,b,c,d,e或f");NO=getchar();switch(NO){case'a':input();break;case'b':search();break;case'c':preserve();break;case'd':planeadd();break;case'e':delplane();break;case'f':quit=1;break;}}while(!quit);}voidinput(){inti,n;FILEfp;system("cls");if((fp=
4、fopen("D:\file","wb"))==NULL){printf("error!");exit(0);}printf("请输入航班总数n:");scanf("%d",&n);printf("请按下面提示输入航班信息:起点站:沈阳");for(i=0;i5、s",a[i].time);printf("t票价:");scanf("%d",&a[i].price);printf("t机票总数:");scanf("%d",&a[i].amount);fwrite(&a[i],sizeof(PLANE),1,fp);}fclose(fp);}voidsearch(){inti,j=0,k=101;charstr[12];FILEfp;PLANEb[5];if((fp=fopen("D:\file","rb"))==NULL){printf("error!");e
6、xit(0);}printf("请输入航班号:");scanf("%s",str);while(fread(&b[j],LEN,1,fp)!=0)j++;for(i=0;i7、。");fclose(fp);system("pause");}voidpreserve(){inta=0,i=0,k,m,n,x;charstr[12];PLANEpreserve[10];FILEfp;if((fp=fopen("D:\file","rb"))==NULL){printf("error!");exit(0);}printf("请输入航班号:");scanf("%s",str);while(fread(&preserve[i],LEN,1,fp)!=0){if(strcmp(preser
8、ve[i].num,str)==0)printf("沈阳至%s航班号:%s时间:%s价格:%d剩余票数:%d",preserve[i].destination,preserve[i].num,preserve[i].time,preserve[i].price,preserve[i].amount);k=i;i++;}fclose(fp);printf("请输入订退票代码:0-订票