# C语言飞机订票系统

C语言飞机订票系统-数据结构课程设计|数据结构课程设计#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)
{
insert_cus(&q,name,air_num,p->total-p->left+1);
p->left--;
return OK;
}
else
{
printf("seat is full");
return 0;
}
}
}

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;

[1] [2] [3] 下一页

C语言飞机订票系统下载如图片无法显示或论文不完整，请联系qq752018766