主题:航空客运订票系统
#include<stdio.h>
#include<malloc.h>
#include<string.h>
#define OK 1
#define ERROR
typedef struct airline{
char air_num[8];
char plan_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)
printf("空间不足");
return a;
}
customer *start_cus()
{
customer *c;
c=(customer * )malloc(sizeof(airline));
if(c==NULL)
printf("空间不足");
return c;
}
airline *modefy_airline(airline *1, char *air_nums)
{
airline *p;
p=1->next;
for(;p!=NULL;p=p->next)
{
if(strcmp(air_num,p->air_num)==0)
{
p->left++;
return 1;
}
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;
}
}
}
int del_cus(customer *c, airline *1, 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);
1=modefy_airline(1,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_num total left\n");
for(;p!=NULL;p=p->next)
{
printf("%s% -10s % -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 **1)
{
airline *p=*1;
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[i],plane_num[i],end_placel[i],total[i],left[i]);
return OK;
}
int creat_cus(customer **1)
{
customer *p=*1;
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[i],air_num[i],seat_num[i]);
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)
{
print("\n");
printf("*************************************\n");
printf("* Welcome to air firm! *\n");
printf("* book----------1 *\n");
printf("* cancle--------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;
}
}
}
}
}
错误提示是:
--------------------Configuration: 航空客运订票系统 - Win32 Debug--------------------
Compiling...
航空客运订票系统.cpp
E:\VC98\航空客运订票系统.cpp(36) : error C2143: syntax error : missing ')' before 'constant'
E:\VC98\航空客运订票系统.cpp(36) : error C2143: syntax error : missing ';' before 'constant'
E:\VC98\航空客运订票系统.cpp(36) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
航空客运订票系统.obj - 3 error(s), 0 warning(s)
麻烦各位帮忙看看,非常感谢!!
#include<malloc.h>
#include<string.h>
#define OK 1
#define ERROR
typedef struct airline{
char air_num[8];
char plan_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)
printf("空间不足");
return a;
}
customer *start_cus()
{
customer *c;
c=(customer * )malloc(sizeof(airline));
if(c==NULL)
printf("空间不足");
return c;
}
airline *modefy_airline(airline *1, char *air_nums)
{
airline *p;
p=1->next;
for(;p!=NULL;p=p->next)
{
if(strcmp(air_num,p->air_num)==0)
{
p->left++;
return 1;
}
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;
}
}
}
int del_cus(customer *c, airline *1, 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);
1=modefy_airline(1,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_num total left\n");
for(;p!=NULL;p=p->next)
{
printf("%s% -10s % -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 **1)
{
airline *p=*1;
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[i],plane_num[i],end_placel[i],total[i],left[i]);
return OK;
}
int creat_cus(customer **1)
{
customer *p=*1;
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[i],air_num[i],seat_num[i]);
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)
{
print("\n");
printf("*************************************\n");
printf("* Welcome to air firm! *\n");
printf("* book----------1 *\n");
printf("* cancle--------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;
}
}
}
}
}
错误提示是:
--------------------Configuration: 航空客运订票系统 - Win32 Debug--------------------
Compiling...
航空客运订票系统.cpp
E:\VC98\航空客运订票系统.cpp(36) : error C2143: syntax error : missing ')' before 'constant'
E:\VC98\航空客运订票系统.cpp(36) : error C2143: syntax error : missing ';' before 'constant'
E:\VC98\航空客运订票系统.cpp(36) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
航空客运订票系统.obj - 3 error(s), 0 warning(s)
麻烦各位帮忙看看,非常感谢!!