#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>//overflow
#define ok 1
typedef struct Yidingkehu
{
char name[15];
int dingpiaoshu;
struct Yidingkehu *next1;
}Yidingkehu,*Link;
typedef struct Weidingkehu
{
char name[15];
int yudingpiao;
struct Weidingkehu *next2;
}Weidingkehu,*Qptr;
typedef struct Hangxian
{
char hangbanhao[15];
char feijihao[15];
int feixingriqi;
int chenkerenshu;
int yupiao;
char zhongdianzhai[15];
struct Hangxian *next;
struct Yidingkehu *yiding;
struct Weidingkehu *yudingqueue;
}Hangxian,*Linklist;
Linklist InitLinklist();
int InsertLinklist(Linklist &head1);
void hbhchaxun();
void mddchaxun();
void lurugongneng();
void chaxungongnen();/
void dingpiaogongnen();
void tuipiaogongnen();
void main()
{
int n;
do{
printf("\t 欢迎使用航空客运订票系统\n");
printf("\t+++++++++++++++++++++++++++++\n");
printf("\t==>1. 录入功能 ==\n");
printf("\t==>2. 查询功能 ==\n");
printf("\t==>3. 订票功能 ==\n");
printf("\t==>4. 退票功能 ==\n");
printf("\t==>5. 退出 ==\n");
printf("\t+++++++++++++++++++++++++++++\n");
printf("\t请选择:");
scanf("%d",&n);printf("\n");
switch(n)
{
case 1: lurugongneng();
break;
case 2: chaxungongnen();
break;
case 3: dingpiaogongnen();
break;
case 4:tuipiaogongnen();
break;
default :exit(0);
}
}while(n==1||n==2||n==3||n==4);
}
void lurugongneng()
{
Linklist p;
//int m,n;
if(!p) exit(OVERFLOW);
printf("\t请依次输入下面几项内容:\n\n");
printf("航班号\n");
gets(p->hangbanhao);
gets(p->hangbanhao);
printf("飞机号\n");
gets(p->feijihao);
printf("终点站\n");
gets(p->zhongdianzhai);
printf("飞行日期\n");
scanf("%d",&p->feixingriqi);
printf("乘客总数\n");
scanf("%d",&p->chenkerenshu);
printf("余票数\n");
scanf("%d",&p->yupiao);
}
void chaxungongnen()
{
int n;
printf("\t 查 找 航 线 信 息 \n");
printf("\t+++++++++++++++++++++++++++++\n");
printf("\t==>1. 通过目的地查询 ==\n");
printf("\t==>2. 通过航班号查询 ==\n");
printf("\t+++++++++++++++++++++++++++++\n");
printf("\t请选择:");
scanf("%d",&n);
printf("\n");
switch(n)
{
case 1:mddchaxun();
break;
case 2:hbhchaxun();
break;
default :break;
}
}
void mddchaxun()
{
char c[15];
int m;
Linklist p=L;
printf("\t请输入要查询的目的地:");
gets(c);
gets(c);
do{
p=p->next;
if(p)
{
m=strcmpi((*p).zhongdianzhai,c);
if(m==0)
{
printf("\t航班信息:\n");
printf("\t航班号:%s\n",p->hangbanhao);
printf("\t飞机号:%s\n",p->feijihao);
printf("\t飞行时间:周%d\n",p->feixingriqi);
printf("\t余票量:%d\n",p->yupiao);
}
}
else
{
printf("\t对不起没有你要找的目的地:\n\n"); m=0;
}
}while(m!=0);
}
void hbhchaxun()
{
char c[15];
int m;
Linklist p=L;
printf("\t请输入要查询的航班号:");
gets(c); gets(c);printf("\n");
do{
p=p->next;
if(p)
{
m=strcmpi((*p).hangbanhao,c);
if(m==0)
{
printf("\t航班信息:\n");
printf("\t航班号:%s\n",p->hangbanhao);
printf("\t飞机号:%s\n",p->feijihao);
printf("\t飞行时间:周%d\n",p->feixingriqi);
printf("\t余票量:%d\n\n",p->yupiao);
}
}
else
{
printf("\t对不起没有你要找的航班号:\n"); m=0;
}
}while(m!=0);
}
void dingpiaogongnen()
{
char c[15];
int m=1,piao,ydpiao=0,yd=0,n;//
gets(c);
printf("请输入终点站名:"); gets(c); printf("\n");
p=L->next;
if(p) {
do{
if(!p)
{
printf("对不起,没有你要找的航班:\n\n");
goto loop1;
}
m=strcmpi(p->zhongdianzhai,c);
if(m==0)
{
printf("航班信息:\n");
printf("航班号:%s\n",p->hangbanhao);
printf("飞机号:%s\n",p->feijihao);
printf("飞行时间:周%d\n",p->feixingriqi);
printf("余票量:%d\n",p->yupiao);}
else p=p->next;
}while(m!=0);
if(m==0)
{
do{
printf("\n请输入你要订的票数:"); scanf("%d",&piao);
if(piao<=p->yupiao)
{
h=p->yiding;
if(h)
{
h1=h;
h=h->next1;
h=(struct Yidingkehu*)malloc(sizeof(Yidingkehu));
printf("请输入你的名字:");
gets(h->name);gets(h->name);
h->dingpiaoshu=piao;
h->next1=h1->next1;
h1->next1=h;
p->yupiao=p->yupiao-piao;
printf("订票成功:\n"); m=2;
}
}
else
{
printf("余票量:%d\n",p->yupiao);
printf("对不起,余票 %d 张不足,不能完成订票\n\n",p->yupiao);
printf(" 是否要重新订票?\n");
printf("需要请输入1 否则请按2 预订请输入3 : ");
scanf("%d",&m);
printf("\n");
if(m==3) goto loop3;
}
}while(m==1);
}
}
else if(!p)
{
loop3: struct Weidingkehu *q3;
printf("对不起,该航班的票已售完\n");
q.front=p->yudingqueue;
if(q.front==q.rear) printf("没有人预订票,是否要预订?\n");
else if(q.front!=q.rear) printf("已有人预订票,是否要预订?\n");
printf("预订请输入1 否则输入2 : ");
scanf("%d",&n);
printf("\n");
if(n==1)
{
printf("请输入你的姓名"); gets(q3->name); gets(q3->name);
printf("请输入订票数"); scanf("%d",&q3->yudingpiao);
q3->next2=NULL;
q.rear->next2=q3;
q.rear=q3;
printf(" 你已经预订了 !\n");
}
}
loop1:;
}
void tuipiaogongnen()
{
}
看下这个是那里错了?