开发工具:
文件大小: 31kb
下载次数: 0
上传时间: 2009-12-29
详细说明: #include #include #include #include #define OK 1 #define ERROR 0 typedef struct airline{ char air_num[8]; char plane_num[8]; char end_place[20]; int total; int left; struct airline *next; }airline; typedef struct customer{ char name[8]; char air_num[8]; int seat_num; struct customer *next; }customer; airline *start_air() { airline *a; a=(airline*)malloc(sizeof(airline)); if(a==NULL) a->next=NULL; return a; } customer *start_cus() { customer *c; c=(customer*)malloc(sizeof(customer)); if(c==NULL) c->next=NULL; return c; } airline *modefy_airline(airline *l,char *air_num) { airline *p; p=l->next; for(;p!=NULL;p=p->next) { if(strcmp(air_num,p->air_num)==0) { p->left++; return l; } printf("NO the airline!"); return 0; } } int insert_air(airline **p,char *air_num,char *plane_num,char *end_place,int total,int left) { airline *q; q=(airline*)malloc(sizeof(airline)); strcpy(q->air_num,air_num); strcpy(q->plane_num,plane_num); strcpy(q->end_place,end_place); q->total=total; q->left=left; q->next=NULL; (*p)->next=q; (*p)=(*p)->next; return OK; } int insert_cus(customer **p,char *name,char *air_num,int seat_num) { customer *q; q=(customer*)malloc(sizeof(customer)); strcpy(q->name,name); strcpy(q->air_num,air_num); q->seat_num=seat_num; q->next=NULL; (*p)->next=q; (*p)=(*p)->next; return OK; } int book(airline *a,char *air_num,customer *c,char *name) { airline *p=a; customer *q=c->next; p=a->next; for(;q->next!=NULL;q=q->next){} for(;p->next!=NULL;p=p->next) { if(p->left>0) { printf("Your seat number is %d",(p->total-p->left+1)); insert_cus(&q,name,air_num,p->total-p->left+1); p->left--; return OK; } else { printf("seat is full"); return 0; } } return OK; } int del_cus(customer *c,airline *l,char *name) { customer *p,*pr; char air_num[8]; pr=c; p=pr->next; while(p!=NULL) { if(strcmp(p->name,name)==0) { strcpy(air_num,p->air_num); l=modefy_airline(l,air_num); pr->next=p->next; p=pr->next; printf("finish!"); return OK; } pr=pr->next; p=pr->next; } printf("NO the customer!"); return ERROR; } int search_air(airline *head) { airline *p=head->next; printf("air_num plane_num end_place total left\n"); for(;p!=NULL;p=p->next) { printf("%s %-10s %-8s %-8d%-8d\n",p->air_num,p->plane_num,p->end_place,p->total,p->left); } return OK; } int search_cus(customer *head) { struct customer *q=head->next; printf("name air_num seat_num\n"); for(;q!=NULL;q=q->next) { printf("%-8s%-12s%-d\n",q->name,q->air_num,q->seat_num); } return OK; } int creat_air(airline **l) { airline *p=*l; int i=0; char *air_num[3]={"007af","008af","009af"}; char *plane_num[3]={"plane1","plane2","plane3"}; char *end_place[3]={"Beijing","Shanghai","Tianjin"}; int total[3]={100,100,100}; int left[3]={52,54,76}; for(i=0;i<3;i++) insert_air(&p,air_num,plane_num,end_place,total,left); return OK; } int creat_cus(customer **l) { customer *p=*l; int i=0; char *name[3]={"zhsan","lisi","wangwu"}; char *air_num[3]={"007af","008af","009af"}; int seat_num[3]={2,5,7}; for(i=0;i<3;i++) insert_cus(&p,name,air_num,seat_num); return OK; } void main() { int t=1; customer *cus=start_cus(); airline *air=start_air(); char name[8],air_num[8],ch; creat_air(&air); creat_cus(&cus); while(t==1) { printf("\n"); printf("*********************************\n"); printf("* Welcome to air firm! *\n"); printf("* book--------1 *\n"); printf("* cancel------2 *\n"); printf("* search------3 *\n"); printf("* exit--------4 *\n"); printf("*********************************\n"); ch=getch(); if(ch=='1') { printf("Please input a airline number:"); scanf("%s",air_num); printf("Please input a name:"); scanf("%s",name); book(air,air_num,cus,name); } else if(ch=='2') { printf("Please input the cancel name:"); scanf("%s",name); del_cus(cus,air,name); } else if(ch=='3') { search_air(air); printf("\n"); search_cus(cus); } else if(ch=='4') { t=0; ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.