为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

航空订票系统

2017-10-07 8页 doc 25KB 22阅读

用户头像

is_554469

暂无简介

举报
航空订票系统航空订票系统 #include #include #include #define ok 1 #define error 0 int n; typedef struct khlist{/*?Í??Ãûµ?*/ char name[20]; char identification[18]; char tostation[10]; int number; struct khlist *next; }qnode,*queueptr; typedef struct {/*Ô?Ô??Í??Ãûµ?*/ ...
航空订票系统
航空订票系统 #include #include #include #define ok 1 #define error 0 int n; typedef struct khlist{/*?Í??Ãûµ?*/ char name[20]; char identification[18]; char tostation[10]; int number; struct khlist *next; }qnode,*queueptr; typedef struct {/*Ô?Ô??Í??Ãûµ?*/ queueptr front; queueptr rear; }linkqueue; typedef struct airlist{/*º?Ïß?íÖÐ??Ïî*/ char tostation[10];/*ÖÕµãÕ?*/ char flight[10];/*º??àºÅ*/ int flycode;/*?É?úºÅ*/ int total; /*?ËÔ????î*/ int left; /*ÓàÆ??î*/ char date[10];/*?ÉÐÐÔçÆÚ*/ qnode *L; /*ÒÑ??Æ?µÄ?Í??Ãûµ?*/ linkqueue *Q; /*Ô?Ô??Í??Ãûµ?*/ }airlist; void Createl(qnode *L){ /*?õÊ???Ô???Æ?Ãûµ?*/ L=(queueptr)malloc(sizeof(qnode)); L->next=NULL;} void initq(linkqueue *Q){/*?õÊ???Ô?Ô?Ãûµ?*/ Q->front=Q->rear=(queueptr)malloc(sizeof(qnode)); if(!Q->front)exit(error); Q->front->next=NULL; } void Createlist(){/*????º?Ïß?í*/ FILE *fp8; int i;airlist *elem; printf("changdu\n");/*º?Ïß?í???È*/ scanf("%d",&n); elem=(airlist *)malloc(n*sizeof(airlist)); puts("please put in data:\n"); printf("***************************************************************\n"); printf("tostation flight flycode total left date \n"); for(i=0;iname,q->identification,q->tostation,&q->number); p=(queueptr)malloc(sizeof(qnode)); if(!p)exit(error); strcpy(p->name,q->name);p->number=q->number; Q->rear->next=p; Q->rear=p; } void dequeue(linkqueue *Q){ /*É??ýÔ?Ô??Í??*/ qnode *p; p=Q->front->next; Q->front->next=p->next; if(Q->rear==p)Q->rear=Q->front; free(p); } qnode *init_L(qnode *L){ /*Ìí?Ó??Æ??Í??*/ qnode *p,*q; q=(queueptr)malloc(sizeof(qnode)); q->next=NULL; printf("khlist\n"); /*ÊäÈë?Í??Ãûµ?*/ printf("**********************************************\n"); printf("name tostation number\n"); scanf("%s%s%d",q->name,q->tostation,&q->number); p=L; while(p->next!=NULL)p=p->next; p->next=q; return L; } qnode *Deletel(qnode *L){/*É??ý??Æ??Í??*/ char name[20];qnode *p,*q=NULL; printf("shuruxingming\n"); scanf("%s",name); p=L; while(strcmp(name,p->next->name)&&p->next!=NULL) p=p->next; if(strcmp(name,p->next->name)==0){q=p->next;p->next=q->next;} return q;/*?µ?Ø?Í??ÐÅÏ?*/ } void putof(){/*Êä?ö?Í???éÑ?ÐÅÏ?*/ FILE *fp9; airlist *al; char tostation[10]; int i; al=(airlist *)malloc(n*sizeof(airlist)); printf("please put in tostation\n"); scanf("%s",tostation);/*ÊäÈëÕ?µãÃû*/ if((fp9=fopen("datafile8","rb"))!=NULL) /*?ÁÈ?º?Ïß?ÇÂ?*/ fread(al,sizeof(airlist),n,fp9); for(i=0;strcmp(al[i].tostation,tostation)&&i<=n;i++); if(strcmp(al[i].tostation,tostation)==0){ /*Êä?öº?Ïß?ÇÂ?*/ printf("flight:%s\nflycode:%d\ntotal:%d\nleft:%d\ndate:%s\n",al[i].flight,al[i].flycode, al[i].total,al[i].left,al[i].date); printf("comingflydate:%s\ncomingflyleft:%d\n",al[i].date,al[i].left); getch();} else {printf("error\n");getch();} fclose(fp9);} void book(){ /*?Í???øÐÐ??Æ?*/ char tostation[10],ch,name[20]; FILE *fp9,*fp6; airlist *aL,*al; int i,k; aL=(airlist *)malloc(n*sizeof(airlist)); printf("please put in tostation\n"); scanf("%s",tostation); /*ÊäÈëÕ?µãÃû*/ if((fp9=fopen("datafile8","rb+"))!=NULL) /*?ÁÈ?º?Ïß?ÇÂ?*/ fread(aL,sizeof(airlist),n,fp9); for(i=0;strcmp(aL[i].tostation,tostation)&&i<=n;i++); if(strcmp(aL[i].tostation,tostation)==0){ printf("please put in number\n"); scanf("%d",&k); if(aL[i].left>=k){aL[i].left-=k;aL[i].L=init_L(aL[i].L); if((fp6=fopen("datafile8","wb+"))!=NULL)/*Ð?Èë?Í??ÐÅÏ?*/ fwrite(aL,sizeof(airlist),n,fp6); fclose(fp6); printf("ok\n");} else printf("not left do you want:'y'or'n'\n");/*Èç?ûÃ?ÓÐ?àÓàÆ?ÎÊ?Í??ÊÇ?ñÔ?Ô?*/ ch=getch(); if(ch=='y'){enqueue(aL[i].Q);printf("please wait\n");getch();} if(ch=='n')return;} else {printf("not find\n");getch();} fclose(fp9);} void draw(){/*?Í???øÐÐÍËÆ?*/ char name[20],tostation[10];int i;qnode *q; airlist *al; FILE *fp6,*fp9; al=(airlist *)malloc(n*sizeof(airlist)); printf("please put in tostation\n"); scanf("%s",tostation); /*ÊäÈëÕ?µãÃû*/ if((fp6=fopen("datafile8","rb+"))!=NULL) /*?ÁÈ?º?Ïß?íÐÅÏ?*/ fread(al,sizeof(airlist),n,fp6); fclose(fp6); for(i=0;strcmp(al[i].tostation,tostation)&&i<=n;i++); if(strcmp(al[i].tostation,tostation)==0){/*ÊÇ?ñ?ûºÏÇé?ö*/ q=Deletel(al[i].L); if(q==NULL) {printf("meiyounidejilu\n");getch();} else{ al[i].left+=q->number; if((fp9=fopen("datafile8","wb+"))!=NULL) fwrite(al,sizeof(airlist),n,fp9); fclose(fp9); if(al[i].Q->rear==al[i].Q->front){printf("meiyouyuyuekehu\n");getch();} /*Ã?ÓÐÔ?Ô??Í??*/ else {dequeue(al[i].Q);printf("checked\n"); getch();}}} else printf("error\n");getch(); } void main(){char ch; Createlist(); end:printf("*************\n"); printf("*1 seach *\n"); printf("*2 book *\n"); printf("*3 draw *\n"); printf("*5 exit *\n"); printf("*************\n"); ch=getch(); switch(ch) {case '1': putof();goto end; case '2': book();goto end; case '3': draw();goto end; case '5': printf("********Thank you!!!*********");getch();break; default:printf("***********error please replay************\n");getch();goto end; } }
/
本文档为【航空订票系统】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
热门搜索

历史搜索

    清空历史搜索