#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
typedef struct EconomyType{
int EcoSeatings; //经济舱座位数
char EcoSeatNum[4][54]; //经济舱全部座位号
float EcoFares; //经济舱票价
float EcoFaDis; //经济舱折扣
}EconomyType; //经济舱相关信息
typedef struct BusinessType{
int BusSeatings; //商务舱座位数
char BusSeatNum[4][24]; //商务舱全部座位号
float BusFares; //商务舱票价
float BusFaDis; //商务舱折扣
}BusinessType; //商务舱相关信息
typedef struct Flight{
char FlightNum[7]; //航班号
char AirType[4]; //航班机型(Big:大型机 ;Mid: 中型机)
char TakeCity[30]; //起飞城市
char LandCity[30]; //降落城市
char TakeTime[30]; //起飞时间
char LandTime[30]; //降落时间
EconomyType ET; //经济舱相关信息
BusinessType BT; //商务舱相关信息
struct Flight * Next; //指向链表中下一个航班信息的结点
}Flight; //航班相关信息
typedef struct CustomerInfo{
char CustName[30]; //用户姓名
char IDNum[19]; //用户身份证号码
char Gender[7]; //用户性别
char CabinType[4]; //机舱类型(Eco:经济舱;Bus:商务舱)
float Fares; //机票费用
char FlightNum[7];
char TakeCity[30];
char LandCity[30];
char TakeTime[30];
char LandTime[30];
char AirTicketNum[13]; //机票号
char SeatNum[4]; //座位号
struct CustomerInfo * Next; //指向链表中下一个机票信息的结点
}CustomerInfo; //机票相关信息
void Menu(){
printf(" ********************************************************\n\n");
printf(" =============您好!欢迎进入航空订票系统。===============\n\n");
printf(" * 航班信息录入(请按1) *\n");
printf(" * 航班信息查询(请按2) *\n");
printf(" * 航班信息修改(请按3) *\n");
printf(" * 航班信息删除(请按4) *\n");
printf(" * 订购机票业务办理(请按5) *\n");
printf(" * 退订机票业务办理(请按6) *\n");
printf(" * 查询订单详情(请按7) *\n");
printf(" * 退出系统(请按0) *\n\n");
}
void WriteInFlight(Flight *F){
int i;
Flight *P=F->Next;
FILE * fp=fopen("d:\\study\\Flight.txt","w+");
if(fp==NULL){
printf("cannot open this file\n");
exit(0);}
while(P!=NULL){
fprintf(fp,"\n%s %s %s %s %s %s %d %.2f %.2f %d %.2f %.2f\n",P->FlightNum,P->AirType,P->TakeCity,P->LandCity,P->TakeTime,P->LandTime,P->ET.EcoSeatings,P->ET.EcoFares,P->ET.EcoFaDis,P->BT.BusSeatings,P->BT.BusFares,P->BT.BusFaDis);
if(strcmp(P->AirType,"Mid")==0){
for (i=0;i<30;i++){
fprintf(fp," %d%c",P->ET.EcoSeatNum[1][i],P->ET.EcoSeatNum[2][i]);
}
for (i=0;i<12;i++){
fprintf(fp," %d%c",P->BT.BusSeatNum[1][i],P->BT.BusSeatNum[2][i]);
}
}
if(strcmp(P->AirType,"Big")==0){
for (i=0;i<54;i++){
fprintf(fp," %d%c",P->ET.EcoSeatNum[1][i],P->ET.EcoSeatNum[2][i]);
}
for (i=0;i<24;i++){
fprintf(fp," %d%c",P->BT.BusSeatNum[1][i],P->BT.BusSeatNum[2][i]);
}
}
P=P->Next;
}
fclose(fp);
}
Flight * WriteOutFlight(Flight * F){
int i,c;
Flight * Q=NULL;
FILE * fp=fopen("d:\\study\\Flight.txt","r");
if(fp==NULL){
printf("cannot open this file\n");
exit(0);}
fseek(fp,0,2);
c=ftell(fp);
rewind(fp);
while(c!=ftell(fp)){
Q=(Flight *)malloc(sizeof(Flight));
fscanf(fp,"%s%s%s%s%s%s%d%f%f%d%f%f",Q->FlightNum,Q->AirType,Q->TakeCity,Q->LandCity,Q->TakeTime,Q->LandTime,&Q->ET.EcoSeatings,&Q->ET.EcoFares,&Q->ET.EcoFaDis,&Q->BT.BusSeatings,&Q->BT.BusFares,&Q->BT.BusFaDis);
if(strcmp(Q->AirType,"Mid")==0){
for (i=0;i<30;i++){
fscanf(fp,"%d",&Q->ET.EcoSeatNum[1][i]);
fscanf(fp,"%c",&Q->ET.EcoSeatNum[2][i]);
}
for (i=0;i<12;i++){
fscanf(fp,"%d",&Q->BT.BusSeatNum[1][i]);
fscanf(fp,"%c",&Q->BT.BusSeatNum[2][i]);
}
}
if(strcmp(Q->AirType,"Big")==0){
for (i=0;i<54;i++){
fscanf(fp,"%d",&Q->ET.EcoSeatNum[1][i]);
fscanf(fp,"%c",&Q->ET.EcoSeatNum[2][i]);
}
for (i=0;i<24;i++){
fscanf(fp,"%d",&Q->BT.BusSeatNum[1][i]);
fscanf(fp,"%c",&Q->BT.BusSeatNum[2][i]);
}
}
Q->Next=F->Next;
F->Next=Q;
}
fclose(fp);
return F;
}
void WriteInCustomerInfo(CustomerInfo *C){
CustomerInfo * R=C->Next;
FILE * fp=fopen("d:\\study\\CustomerInfo.txt","w+");
if(fp==NULL){
printf("cannot open this file\n");
exit(0);}
while(R!=NULL){
fprintf(fp,"\n%s %s %s %s %.2f %s %s %s %s %s %s %d%c",R->CustName,R->IDNum,R->Gender,R->CabinType,R->Fares,R->FlightNum,R->TakeCity,R->LandCity,R->TakeTime,R->LandTime,R->AirTicketNum,R->SeatNum[1],R->SeatNum[2]);
R=R->Next;
}
fclose(fp);
}
CustomerInfo * WriteOutCustomerInfo(CustomerInfo *C){
int c;
CustomerInfo * Q=NULL;
FILE * fp=fopen("d:\\study\\CustomerInfo.txt","r");
if(fp==NULL){
printf("cannot open this file\n");
exit(0);}
fseek(fp,0,2);
c=ftell(fp);
rewind(fp);
printf("~~~");
while(c!=ftell(fp)){
Q=(CustomerInfo *)malloc(sizeof(CustomerInfo));
printf("@@@");
fscanf(fp,"%s%s%s%s%f%s%s%s%s%s%s",Q->CustName,Q->IDNum,Q->Gender,Q->CabinType,&Q->Fares,Q->FlightNum,Q->TakeCity,Q->LandCity,Q->TakeTime,Q->LandTime,Q->AirTicketNum);
printf("%s",Q->CustName);
fscanf(fp,"%d",&Q->SeatNum[1]);
printf("%d",Q->SeatNum[1]);
fscanf(fp,"%c",&Q->SeatNum[2]);
printf("%c",Q->SeatNum[2]);
printf("%s %s %s %s %.2f %s %s %s %s %s %s %d%c",Q->CustName,Q->IDNum,Q->Gender,Q->CabinType,Q->Fares,Q->FlightNum,Q->TakeCity,Q->LandCity,Q->TakeTime,Q->LandTime,Q->AirTicketNum,Q->SeatNum[1],Q->SeatNum[2]);
Q->Next=C->Next;
C->Next=Q;
}
fclose(fp);
return C;
}
void QAT(Flight *Q,int z,int y){
int i,j;
Q->ET.EcoSeatings=z;
for (i=0,j=1;i<z;i+=6,j++){
Q->ET.EcoSeatNum[1][i]=j; Q->ET.EcoSeatNum[2][i]='A';
Q->ET.EcoSeatNum[1][i+1]=j;Q->ET.EcoSeatNum[2][i+1]='B';
Q->ET.EcoSeatNum[1][i+2]=j;Q->ET.EcoSeatNum[2][i+2]='C';
Q->ET.EcoSeatNum[1][i+3]=j;Q->ET.EcoSeatNum[2][i+3]='D';
Q->ET.EcoSeatNum[1][i+4]=j;Q->ET.EcoSeatNum[2][i+4]='E';
Q->ET.EcoSeatNum[1][i+5]=j;Q->ET.EcoSeatNum[2][i+5]='F';
}
Q->BT.BusSeatings=y;
for (i=0,j=1;i<y;i+=6,j++) {
Q->BT.BusSeatNum[1][i]=j; Q->BT.BusSeatNum[2][i]='A';
Q->BT.BusSeatNum[1][i+1]=j;Q->BT.BusSeatNum[2][i+1]='B';
Q->BT.BusSeatNum[1][i+2]=j;Q->BT.BusSeatNum[2][i+2]='C';
Q->BT.BusSeatNum[1][i+3]=j;Q->BT.BusSeatNum[2][i+3]='D';
Q->BT.BusSeatNum[1][i+4]=j;Q->BT.BusSeatNum[2][i+4]='E';
Q->BT.BusSeatNum[1][i+5]=j;Q->BT.BusSeatNum[2][i+5]='F';
}
}
void SNWrite(Flight *Q){
if(strcmp(Q->AirType,"Mid")==0){
QAT(Q,30,12);
}
if(strcmp(Q->AirType,"Big")==0){
QAT(Q,54,24);
}
}
void PrintAirInfo(Flight *P,int &t,int n){
int i;
printf("\n 航班号 机型 出发城市 到达城市 出发时间 到达时间 \n");
printf(" %s %s %s %s %s %s\n",P->FlightNum,P->AirType,P->TakeCity,P->LandCity,P->TakeTime,P->LandTime);
printf("经济舱相关信息(座位数 价格 折扣):");printf("%d %.2f %.2f\n",P->ET.EcoSeatings,P->ET.EcoFares,P->ET.EcoFaDis);
if(n==1){
printf("经济舱剩余座位:\n");
if(strcmp(P->AirType,"Mid")==0){
for(i=0;i<30;i++)
printf(" %d%c\t",P->ET.EcoSeatNum[1][i],P->ET.EcoSeatNum[2][i]);
}
if(strcmp(P->AirType,"Big")==0){
for(i=0;i<54;i++)
printf(" %d%c\t",P->ET.EcoSeatNum[1][i],P->ET.EcoSeatNum[2][i]);
}
}
printf("\n商务舱相关信息(座位数 价格 折扣):");printf("%d %.2f %.2f\n",P->BT.BusSeatings,P->BT.BusFares,P->BT.BusFaDis);
if(n==1){
printf("商务舱剩余座位:\n");
if(strcmp(P->AirType,"Mid")==0){
for(i=0;i<12;i++)
printf(" %d%c\t",P->BT.BusSeatNum[1][i],P->BT.BusSeatNum[2][i]);
}
if(strcmp(P->AirType,"Big")==0){
for(i=0;i<24;i++)
printf(" %d%c\t",P->BT.BusSeatNum[1][i],P->BT.BusSeatNum[2][i]);
}
}
t=1;
printf("\n\n");
}
void InputFliInfo(Flight *F){
int none=1;
int chioce;
while(none){
Flight * P=F;
Flight * Q=(Flight *)malloc(sizeof(Flight));
getchar();
printf("请根据提示,输入航班信息!\n");
printf("航班号:"); scanf("%s",Q->FlightNum);
printf("机型:"); scanf("%s",Q->AirType);
printf("出发城市:"); scanf("%s",Q->TakeCity);
printf("到达城市:"); scanf("%s",Q->LandCity);
printf("出发时间:"); scanf("%s",Q->TakeTime);
printf("到达时间:"); scanf("%s",Q->LandTime);
printf("经济舱票价相关信息(价格 折扣):");scanf("%f %f",&Q->ET.EcoFares,&Q->ET.EcoFaDis);
printf("商务舱票价相关信息(价格 折扣):");scanf("%f %f",&Q->BT.BusFares,&Q->BT.BusFaDis);
SNWrite(Q);
Q->Next=P->Next;
P->Next=Q;
P=P->Next;
printf("是否需要继续添加航班信息(是-按任意键(除0) 否-按0):");scanf("%d",&chioce);
if(chioce==0){
none=0;
}
}
}
void FliInfoSearch(Flight *F){
Flight * P=F;
int chioce,t=0;
char FN[6],TC[30],LC[30];
printf("请选择查询航班方式(按1以航班号查询,按任意键(除1)以起降城市查找):");scanf("%d",&chioce);
if(chioce==1){
getchar();
printf("请输入需查询的航班号:");scanf("%s",FN);
while(P!=NULL){
if(strcmp(P->FlightNum,FN)==0){
PrintAirInfo(P,t,1);
break;
}
P=P->Next;
if(P==NULL&&t==0)
printf("未查询到该航班!");
}
}
else{
getchar();
printf("请输入出发城市与到达城市:"); scanf("%s %s",TC,LC);
while(P!=NULL){
if(strcmp(P->TakeCity,TC)==0&&strcmp(P->LandCity,LC)==0){
PrintAirInfo(P,t,1);
}
P=P->Next;
if(P==NULL&&t==0)
printf("未查询到该航班!");
}
}
}
void FliInfoModify(Flight *F){
Flight * P=F;
char FN[7];
int none=1,chioce,XG,t=1;
getchar();
printf("请输入需要修改航班信息的航班号:");scanf("%s",FN);
while(P!=NULL){
if(strcmp(P->FlightNum,FN)==0){
while(none){
printf("1-航班号;2-机型;3-出发城市;4-到达城市;5-出发时间;6-到达时间;7-经济舱相关信息;8-商务舱相关信息\n");
printf("请选择需要修改的信息(输入序号):");
scanf("%d",&XG);
switch(XG)
{case 1: printf("请输入新的航班号:"); scanf("%s",P->FlightNum); break;
case 2: printf("请输入新的机型:"); scanf("%s",P->AirType); SNWrite(P); break;
case 3: printf("请输入新的出发城市:"); scanf("%s",P->TakeCity); break;
case 4: printf("请输入新的到达城市:"); scanf("%s",P->LandCity); break;
case 5: printf("请输入新的出发时间:"); scanf("%s",P->TakeTime); break;
case 6: printf("请输入新的到达时间:"); scanf("%s",P->LandTime); break;
case 7: printf("请输入新的经济舱相关信息(座位数 票价 折扣):"); scanf("%d %f %f",&P->ET.EcoSeatings,&P->ET.EcoFares,&P->ET.EcoFaDis); break;
case 8: printf("请输入新的商务舱相关信息(座位数 票价 折扣):"); scanf("%d %f %f",&P->BT.BusSeatings,&P->BT.BusFares,&P->BT.BusFaDis); break;
case 0: printf("\n欢迎您下次使用!\n"); exit(0); break;
default: printf("输入错误!");
}
printf("是否需要再修改该航班的其他信息(需要请按任意键(除1),不需要按1退出):");
scanf("%d",&chioce);
if(chioce==1)
none=0;
}t==0;
break;
}
P=P->Next;
if(P==NULL&&t==1){
printf("未查询到该航班!"); }
}
}
void FliInfoDelete(Flight * F){
Flight * P=F;
Flight * Q=NULL;
char FN[7];
getchar();
printf("请输入需要删除航班信息的航班号:");scanf("%s",FN);
while(P!=NULL){
if(strcmp(P->FlightNum,FN)==0){
Q->Next=P->Next;
free(P);
printf("删除成功!");
break;
}
Q=P;
P=P->Next;
if(P==NULL){
printf("未查询到该航班!");
}
}
}
void NoTicket(Flight *F,char *TC,char *LC){
Flight *P=F;
Flight *Q=F;
Flight *R=F;
int t;
while(P!=NULL){
if(strcmp(P->TakeCity,TC)==0){
while(Q!=NULL){
if(strcmp(P->LandCity,Q->TakeCity)==0&&strcmp(Q->LandCity,LC)==0){
PrintAirInfo(P,t,0);
printf("\n");
PrintAirInfo(Q,t,0);
}
Q=Q->Next;
}
}
P=P->Next;
}
}
void BTicket(Flight *P,CustomerInfo * Q,char * FN,char *fn,int &none,char *TC,char *LC){
int i,j,randnum;
char CT[4],SN[4],SS[7];
char strs[37]="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
strcpy(CT,Q->CabinType);
printf("余票尚且支持此次购票数。\n");
if(strcmp(CT,"Eco")==0)
printf("经济舱剩余座位:\n");
if(strcmp(CT,"Bus")==0)
printf("商务舱剩余座位:\n");
if(strcmp(P->AirType,"Mid")==0){
if(strcmp(CT,"Eco")==0){
for(i=0;i<30;i++)
printf(" %d%c\t",P->ET.EcoSeatNum[1][i],P->ET.EcoSeatNum[2][i]);}
if(strcmp(CT,"Bus")==0){
for(i=0;i<12;i++)
printf("%d%c \t",P->BT.BusSeatNum[1][i],P->BT.BusSeatNum[2][i]);}
}
if(strcmp(P->AirType,"Big")==0){
if(strcmp(CT,"Eco")==0){
for(i=0;i<54;i++)
printf(" %d%c\t",P->ET.EcoSeatNum[1][i],P->ET.EcoSeatNum[2][i]);}
if(strcmp(CT,"Bus")==0){
for(i=0;i<24;i++)
printf("%d%c \t",P->BT.BusSeatNum[1][i],P->BT.BusSeatNum[2][i]);}
}
while(none){
printf("\n根据上方空余座位表,请选择座位号( 0X代表座位已有人):");scanf("%d%c",&SN[1],&SN[2]);
if(strcmp(P->AirType,"Mid")==0){
if(strcmp(CT,"Eco")==0){
for(i=0;i<30;i++){
if(SN[1]!=0&&SN[2]!='X'&&SN[1]==P->ET.EcoSeatNum[1][i]&&SN[2]==P->ET.EcoSeatNum[2][i]){
printf("座位挑选成功!");
P->ET.EcoSeatNum[1][i]=0;
P->ET.EcoSeatNum[2][i]='X';
none=0;
break;
}
}
if(30==i){
printf("输入座位号错误或该座位已有乘客。\n");
}
}
if(strcmp(CT,"Bus")==0){
for(i=0;i<12;i++){
if(SN[1]!=0&&SN[2]!='X'&&SN[1]==P->BT.BusSeatNum[1][i]&&SN[2]==P->BT.BusSeatNum[2][i]){
printf("座位挑选成功!");
P->BT.BusSeatNum[1][i]=0;
P->BT.BusSeatNum[2][i]='X';
none=0;
break;
}
}
if(12==i){
printf("输入座位号错误或该座位已有乘客。\n");
}
}
}
if(strcmp(P->AirType,"Big")==0){
if(strcmp(CT,"Eco")==0){
for(i=0;i<54;i++){
if(SN[1]!=0&&SN[2]!='X'&&SN[1]==P->ET.EcoSeatNum[1][i]&&SN[2]==P->ET.EcoSeatNum[2][i]){
printf("座位挑选成功!");
P->ET.EcoSeatNum[1][i]=0;
P->ET.EcoSeatNum[2][i]='X';
none=0;
break;
}
}
if(54==i){
printf("输入座位号错误或该座位已有乘客。\n");
}
}
if(strcmp(CT,"Bus")==0){
for(i=0;i<24;i++){
if(SN[1]!=0&&SN[2]!='X'&&SN[1]==P->BT.BusSeatNum[1][i]&&SN[2]==P->BT.BusSeatNum[2][i]){
printf("座位挑选成功!");
P->BT.BusSeatNum[1][i]=0;
P->BT.BusSeatNum[2][i]='X';
none=0;
break;
}
}
if(24==i){
printf("输入座位号错误或该座位已有乘客。\n");
}
}
}
}
strcpy(Q->FlightNum,FN);
for(j=0;j<5;j++){
randnum=rand()%36;
SS[j]=strs[randnum];
}
strcat(SS,"1");
strcat(fn,SS);
strcpy(Q->AirTicketNum,fn);
Q->SeatNum[1]=SN[1];
Q->SeatNum[2]=SN[2];
if(strcmp(CT,"Eco")==0){
Q->Fares=(P->ET.EcoFaDis)*(P->ET.EcoFares)*0.1;
P->ET.EcoSeatings=P->ET.EcoSeatings-1;
}
if(strcmp(CT,"Bus")==0){
Q->Fares=(P->BT.BusFaDis)*(P->BT.BusFares)*0.1;
P->BT.BusSeatings=P->BT.BusSeatings-1;
}
strcpy(Q->TakeCity,TC);strcpy(Q->LandCity,LC);
strcpy(Q->TakeTime,P->TakeTime);strcpy(Q->LandTime,P->LandTime);
printf("订票成功!机票号为:%s , 座位号为:%d%c , 金额为%.2f。",Q->AirTicketNum,Q->SeatNum[1],Q->SeatNum[2],Q->Fares);
}
void BookTicket(CustomerInfo *C,Flight *F){
char FN[7],fn[13];
char TC[30],LC[30];
int num,none,k,t=0,Seat,n,mc=1;
CustomerInfo *Y=C;
Flight * P=F;
srand(time(NULL));
printf("请输入出发城市和到达城市(空格隔开):");scanf("%s %s",TC,LC);
while(P!=NULL){
if(strcmp(P->TakeCity,TC)==0&&strcmp(P->LandCity,LC)==0){
PrintAirInfo(P,t,0);}
P=P->Next;
if(P==NULL&&t==0){
printf("未查询到该航班!\n");
printf("可选择以下转乘路线:\n");
NoTicket(F,TC,LC);
break;}
}
while(mc){
printf("请输入需要订购的机票的航班号:");scanf("%s",FN);
none=1;
P=F;
strcpy(fn,FN);
CustomerInfo * Q=(CustomerInfo *)malloc(sizeof(CustomerInfo));
printf("请输入机票的票主信息(姓名 身份证号码 性别 机舱类型 ):");
scanf("%s %s %s %s",Q->CustName,Q->IDNum,Q->Gender,Q->CabinType);
while (P!=NULL){
if(strcmp(P->FlightNum,FN)==0){
if(strcmp(Q->CabinType,"Eco")==0)
Seat=P->ET.EcoSeatings;
if(strcmp(Q->CabinType,"Bus")==0)
Seat=P->BT.BusSeatings;
if(1<=Seat){
BTicket(P,Q,FN,fn,none,TC,LC);}
else{
printf("票已不足,是否选择更改机舱类型(0-否,1-是):");scanf("%d",&n);
while(n!=1&&n!=0){
printf("重新选择是否选择更改机舱类型(0-否,1-是):");scanf("%d",&n);
}
if(n==1){
printf("请重新输入机舱类型:");scanf("%s",Q->CabinType);
if(strcmp(Q->CabinType,"Eco")==0)
Seat=P->ET.EcoSeatings;
if(strcmp(Q->CabinType,"Bus")==0)
Seat=P->BT.BusSeatings;
if(1<=Seat){
BTicket(P,Q,FN,fn,none,TC,LC);
}
else{
printf("该机舱类型票也不足!");
printf("可继续选择以下转乘路线:\n");
NoTicket(F,TC,LC);
}
}
if(n==0){
printf("可继续选择以下转乘路线:\n");
NoTicket(F,TC,LC);
}
}
break;
}
P=P->Next;
}
Q->Next=Y->Next;
Y->Next=Q;
Y=Y->Next;
printf("\n\n");
printf("请问是否继续订票(0-否,1-是):");scanf("%d",&mc);
}
}
void YSN(int a,char b,int &p,int &q){
switch(a)
{case 1:p=0;break;
case 2:p=1;break;
case 3:p=2;break;
case 4:p=3;break;
case 5:p=4;break;
case 6:p=5;break;
}
switch(b)
{case 'A':q=0;break;
case 'B':q=1;break;
case 'C':q=2;break;
case 'D':q=3;break;
case 'E':q=4;break;
case 'F':q=5;break;
}
}
void WTicket(CustomerInfo * Y,CustomerInfo * U,Flight * P,char * ATN){
int p,q,sort,t=0;
float m;
while(Y!=NULL){
if(strcmp(Y->AirTicketNum,ATN)==0){
while(P!=NULL){
if(strcmp(P->FlightNum,Y->FlightNum)==0){
if(strcmp(Y->CabinType,"Eco")==0){
YSN(Y->SeatNum[1],Y->SeatNum[2],p,q);
sort=p*10+q;
P->ET.EcoSeatNum[1][sort]=Y->SeatNum[1];
P->ET.EcoSeatNum[2][sort]=Y->SeatNum[2];
P->ET.EcoSeatings+=1;
}
if(strcmp(Y->CabinType,"Bus")==0){
YSN(Y->SeatNum[1],Y->SeatNum[2],p,q);
sort=p*10+q;
P->BT.BusSeatNum[1][sort]=Y->SeatNum[1];
P->BT.BusSeatNum[2][sort]=Y->SeatNum[2];
P->BT.BusSeatings+=1;
}
break;
}
P=P->Next;
}
m=Y->Fares;
U->Next=Y->Next;
free(Y);
printf("退票成功!退还金额:%.2f。",m);
t=1;
break;
}
U=Y;
Y=Y->Next;
if(Y==NULL&&t==0){
printf("未查询到该机票信息。");
}
}
}
void WithdrawTicket(CustomerInfo *C,Flight *F){
char ATN[13],CN[30],IN[19];
int n;
CustomerInfo * Y=C;
CustomerInfo * U=NULL;
Flight * P=F;
printf("请选择: 1.直接通过机票号进行退票; 其他键.通过查询客户信息进行退票。您的选择是:");scanf("%d",&n);
if(1==n){
printf("请输入欲退订的机票的机票号:");scanf("%s",ATN);
WTicket(Y,U,P,ATN);
}
else{
printf("请输入客户的基本信息(姓名 身份证号):");scanf("%s %s",CN,IN);
while(Y!=NULL){
if (strcmp(Y->CustName,CN)==0&&strcmp(Y->IDNum,IN)==0){
printf(" 机票号 客户姓名 航班号 起飞城市 降落城市 支付金额\n");
printf(" %s %s %s %s %s %.2f\n",Y->AirTicketNum,Y->CustName,Y->FlightNum,Y->TakeCity,Y->LandCity,Y->Fares);
}
Y=Y->Next;
}
printf("请输入欲退订的机票的机票号:");scanf("%s",ATN);
Y=C;
WTicket(Y,U,P,ATN);
}
}
void SearchTicket(CustomerInfo *C){
int n,t=0;
char ATN[13],CN[30],IN[19];
CustomerInfo * Y=C;
printf("请选择查询机票方式(按“1”-机票号查询,其他键-用户信息查询):");scanf("%d",&n);
if(n==1){
printf("请输入需查询的机票号:");scanf("%s",ATN);
while(Y!=NULL){
if(strcmp(Y->AirTicketNum,ATN)==0){
printf(" 机票号 客户姓名 航班号 起飞城市 降落城市 座位号 支付金额\n");
printf(" %s %s %s %s %s %d%c %.2f\n",Y->AirTicketNum,Y->CustName,Y->FlightNum,Y->TakeCity,Y->LandCity,Y->SeatNum[1],Y->SeatNum[2],Y->Fares);
t=1;
break;
}
Y=Y->Next;
if(Y==NULL&&t==0)
printf("未查询到该机票信息。");
}
}
else{
printf("请输入客户的基本信息(姓名 身份证号):");scanf("%s %s",CN,IN);
while(Y!=NULL){
if (strcmp(Y->CustName,CN)==0&&strcmp(Y->IDNum,IN)==0){
printf(" 机票号 客户姓名 航班号 起飞城市 降落城市 座位号 支付金额\n");
printf(" %s %s %s %s %s %d%c %.2f\n",Y->AirTicketNum,Y->CustName,Y->FlightNum,Y->TakeCity,Y->LandCity,Y->SeatNum[1],Y->SeatNum[2],Y->Fares);
t=1;
}
Y=Y->Next;
if(Y==NULL&&t==0)
printf("未查询到该机票信息。");
}
}
}
int main(){
int choice;
int Continue;
Flight * F,*P;
CustomerInfo * C;
F=(Flight *)malloc(sizeof(Flight));
C=(CustomerInfo *)malloc(sizeof(CustomerInfo));
F->Next=NULL;
C->Next=NULL;
WriteOutFlight(F);
printf("==%s=",F->Next->FlightNum);
WriteOutCustomerInfo(C);
Menu();
while(1)
{printf("请输入你需要选择的选项(0~7):");scanf("%d",&choice);printf("\n");
/*输入不同值,调用不同的函数*/
switch(choice)
{case 1: InputFliInfo(F); break;
case 2: FliInfoSearch(F); break;
case 3: FliInfoModify(F); break;
case 4: FliInfoDelete(F); break;
case 5: BookTicket(C,F); break;
case 6: WithdrawTicket(C,F); break;
case 7: SearchTicket(C,F); break;
case 0: printf("\n欢迎您下次使用!\n");
WriteInFlight(F);
WriteInCustomerInfo(C);
exit(0); break;
default:printf("\n输入错误!\n");
}
printf("\n\n若继续,请按任意键(除9外),否则按9结束。请输入:"); getchar();
Continue=getchar();printf("\n");
if(Continue=='9')
break;
}
}
航空售票系统源代码
猜你喜欢
转载自blog.csdn.net/qq_45239614/article/details/103667560
今日推荐
周排行