航空订票系统管理无法在DEVC++中编译2,求高手。。。后续
//-----------------订票乘客信息-----------------void Display_Reserve()
{
Line_See();
Flight *p1;
Customer *p2;
p1=Head;
int flag=0,Flight_No=0;
char answer[6];
char *Rank[]=...{"头等舱","经济舱","普通舱"};
if(Empty_Flight())
return;
prefix("定票乘客名单");
if(IsEmpty)
{
cout<<" 对不起,系统中无定票的乘客。"<<endl;
getch();
return;
}
cout<<" 查看哪条航线的乘客信息?"<<endl;
cout<<" 请输入航班号(若找不到则输出所有航线乘客信息):";
cin>>answer;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
cout<<" ┊ 姓名 ┊航班号┊飞机号┊订票量┊ 终点站 ┊ 舱等 ┊ 座位号 ┊"<<endl;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
if (Find_Line(Head,answer,p1,Flight_No))
{
p2=p1->CustName;
while(p2!=NULL)
{
cout<<" ┊"<<setiosflags(ios::left)<<setw(8)<<p2->Name
<<"┊"<<setw(6)<<p1->Flight_No
<<"┊"<<setw(6)<<p1->Plane_No
<<"┊"<<setw(6)<<p2->Amount
<<"┊"<<setw(8)<<p1->Des_Name
<<"┊"<<setw(6)<<Rank[p2->Rank-1]
<<"┊ ";
if(p2->Amount>1)
cout<<setw(3)<<p2->Seat_No<<"-"<<p2->Seat_No+p2->Amount-1<<"┊"<<endl;
else
cout<<setw(6)<<p2->Seat_No<<"┊"<<endl;
p2=p2->Next;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
}
}
else
{
while(p1!=NULL)
{
if(p1->CustName!=NULL)
{
p2=p1->CustName;
while(p2!=NULL)
{
cout<<" ┊"<<setiosflags(ios::left)<<setw(8)<<p2->Name
<<"┊"<<setw(6)<<p1->Flight_No
<<"┊"<<setw(6)<<p1->Plane_No
<<"┊"<<setw(6)<<p2->Amount
<<"┊"<<setw(8)<<p1->Des_Name
<<"┊"<<setw(6)<<Rank[p2->Rank-1]
<<"┊ ";
if(p2->Amount>1)
cout<<setw(3)<<p2->Seat_No<<"-"<<p2->Seat_No+p2->Amount-1<<"┊"<<endl;
else
cout<<setw(6)<<p2->Seat_No<<"┊"<<endl;
p2=p2->Next;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
}
}
p1=p1->Next;
}
}
cout<<" 按任意键返回上一级菜单..."<<endl;
getch();
}
//-----------------候补乘客信息-----------------
void Display_Replace()
{
Line_See();
Flight *p1;
Replace *p2;
p1=Head;
int flag=0,Flight_No=0;
char answer[6];
char *Rank[]=...{"头等舱","经济舱","普通舱"};
if(Empty_Flight())
return;
prefix("候补乘客名单");
if(IsReplace)
{
cout<<" 对不起,系统中无候补乘客。"<<endl;
getch();
return;
}
cout<<" 查看哪条航线的候补乘客信息?"<<endl;
cout<<" 请输入航班号(若找不到则输出所有航线候补信息):";
cin>>answer;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
cout<<" ┊ 姓名 ┊航班号┊飞机号┊订票量┊ 终点站 ┊ 舱等 ┊拟座位号┊"<<endl;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
if (Find_Line(Head,answer,p1,Flight_No))
{
p2=p1->ReplName;
while(p2!=NULL)
{
cout<<" ┊"<<setiosflags(ios::left)<<setw(6)<<p2->Name
<<"┊"<<setw(6)<<p1->Flight_No
<<"┊"<<setw(6)<<p1->Plane_No
<<"┊"<<setw(6)<<p2->Amount
<<"┊"<<setw(8)<<p1->Des_Name
<<"┊"<<setw(6)<<Rank[p2->Rank-1]
<<"┊ ";
if(p2->Amount>1)
cout<<setw(3)<<p2->Seat_No<<"-"<<p2->Seat_No+p2->Amount-1<<"┊"<<endl;
else
cout<<setw(6)<<p2->Seat_No<<"┊"<<endl;
p2=p2->Next;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
}
}
else
{
while(p1!=NULL)
{
if(p1->ReplName!=NULL)
{
p2=p1->ReplName;
while(p2!=NULL)
{
cout<<" ┊"<<setiosflags(ios::left)<<setw(6)<<p2->Name
<<"┊"<<setw(6)<<p1->Flight_No
<<"┊"<<setw(6)<<p1->Plane_No
<<"┊"<<setw(6)<<p2->Amount
<<"┊"<<setw(8)<<p1->Des_Name
<<"┊"<<setw(6)<<Rank[p2->Rank-1]
<<"┊ ";
if(p2->Amount>1)
cout<<setw(3)<<p2->Seat_No<<"-"<<p2->Seat_No+p2->Amount-1<<"┊"<<endl;
else
cout<<setw(6)<<p2->Seat_No<<"┊"<<endl;
p2=p2->Next;
cout<<" ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"<<endl;
}
}
p1=p1->Next;
}
}
cout<<" 按任意键返回上一级菜单..."<<endl;
getch();
}
//-----------------退票办理函数-----------------
void LogoutMenu()
{
int Flight_No=0,flag=0; //记录满足条件的航线的定票结点
Flight *p1; //记下满足条件的航线结点地址
Customer *p2,*p4; //临时性定票乘员结点
Replace *p3,*p5; //临时性候补乘员结点
char answer[7],name[7]; //用户输入的航班数据
int tag=0,last=1; //若第二乘客满足条件,则它的首地址会发生冲突,注意此处
int Seat_No; //记录座位号
if(Empty_Flight()) //航班线为空
return;
prefix("退票办理");
if(IsEmpty)
{
cout<<" 对不起,系统中暂时无定票乘客..."<<endl;
getch();
return;
}
while(1)
{
flag=0;
tag=0;
Flight_No=0;
prefix("退票办理");
cout<<" 请输入航班号:";
cin>>answer;
if(Find_Line(Head,answer,p1,Flight_No)) //航线存在
{
p2=p1->CustName; //指向该航线的乘客名单的首地址
p4=p1->CustName;
cout<<" 请输入您的姓名:";
cin>>name;
if(p2==NULL) //该航线无定票乘客
{
cout<<" 很抱歉,该航线暂时无人定票,无法进行退票操作."<<endl;
if(Continue()=='n')//是否继续操作
return;
else
continue; //提前结束本次循环,重新进行退票处理
}
else
while(p2!=NULL)//查找有无此乘客名
{
if(strcmp(p2->Name,name)==0)
{
if(p2==p1->CustName) //若为首位乘客满足
{
prior=p1->CustName; //记录指针
Seat_No=p2->Seat_No;
flag=1;
break;
}
}
else if(p2->Next!=NULL)//记录满足航线的的前结点地址
{
if(strcmp(p2->Next->Name,name)==0)
{
tag=1; //特别注意此处
prior=p2; //记录满足定乘客的前一地址,以作删除操作
Seat_No=p2->Next->Seat_No;
flag=1;
break;
}
}
p2=p2->Next; //指向下一乘客结点
}//while
if(!flag)
cout<<" 很抱歉,该航线无此乘客,请查证后再操作..."<<endl;
}
else
cout<<" 对不起,没有该次航班,按任意继续操作."<<endl;
if(flag)
{
if(prior==p1->CustName&&!tag) //首结点满足条件且一个乘客,则该航线定票乘客置空
{
if(prior->Next==NULL) //如果只有一个乘客,直接赋值为空
{
p1->Free_Amount+=prior->Amount;
p1->CustNo-=prior->Amount;
p1->CustName=NULL;
}
else
{
p1->Free_Amount+=prior->Amount;
p1->CustNo-=prior->Amount;
p1->CustName=prior->Next; //指向下一乘客结点
}
}
else
{
p1->Free_Amount+=prior->Next->Amount;
p1->CustNo-=prior->Next->Amount;
// cout<<"here0"<<Custp1[Flight_No]->Name;
// cout<<prior->Name;
// cout<<Custp1[Flight_No]->Name;
if(prior->Next->Next==NULL) //若删除的是最后一个订票乘客
{
Custp1[Flight_No]=prior; //把Custp1[Flight_No]往前移
}
else
{
prior->Next=prior->Next->Next; //删除操作
}
}
Customer_Count--;
if(Customer_Count==0)
IsEmpty=1;
}
if(flag)
{
p3=p1->ReplName;
while(p3!=NULL)
{
if(p3->Amount<=p1->Free_Amount) //候补乘客的定票数小于或等于剩余票数
{
p4=Custp1[Flight_No]->Next=new Customer;
Custp1[Flight_No]=p4; //记录节点位置
p4->Next=NULL;
IsEmpty=0;
if(p1->CustName==NULL)
p1->CustName=p4;
strcpy(p4->Name,p3->Name);
// cout<<"名"<<p4->Name;
p4->Rank=p3->Rank;
// cout<<"等"<<p4->Rank;
p4->Amount=p3->Amount;
// cout<<"票"<<p4->Amount;
if (flag==0) //座位号调整
{
p4->Seat_No=Seat_No;
}
else
p4->Seat_No=Seat_No;
Seat_No=p4->Seat_No+p4->Amount; //记录新乘客的下一个座位号
// cout<<"座"<<p4->Seat_No;
p1->Free_Amount-=p3->Amount; //减去相应的票数
p1->ReplNo-=p3->Amount;
p1->CustNo+=p3->Amount;
Customer_Count++;
cout<<" 候补乘员"<<p3->Name<<"已经列入定票乘客名单中... "<<endl;
if(p3->Next==NULL) //无候补乘客
IsReplace=1;
if(p1->ReplName==p3)
{
if(p1->ReplName->Next==NULL)
p1->ReplName=NULL;//删除
else
p1->ReplName=p3->Next;
}
else
p5->Next=p3->Next->Next;
}
if(p3->Next!=NULL)
if(p3->Next->Amount<=p1->Free_Amount)
p5=p3;
p3=p3->Next; //指向下一候补乘客结点
flag=0;
}
cout<<" 退票办理已经操作完毕,按任意键返回菜单..."<<endl;
getch();
return;
}//存在此乘客
if(Continue()=='n')
return;
}//while
}
//---------------乘客管理子菜单函数-----------------
void CustMenu()
{
char *MenuItem[]=
{
"┊ 航空客运乘客管理子菜单 ┊",
" ┊ [1]. 订票乘客信息 ┊ ",
" ┊ [2]. 候补乘客信息 ┊ ",
" ┊ [3]. 返回系统菜单 ┊ "
};
while(1)
switch(ModelMenu(MenuItem,4))
{
case '1':{Display_Reserve();break;}
case '2':{Display_Replace();break;}
case '3':{return;}
default:{ErrorMess();}
}
}
int main()
{
Head=NULL;
int size=sizeof(Flight); //判断文件是否为空,非空则读入
fstream Access("Flight.txt",ios::binary|ios::in);
Access.seekp(0,ios::end);
long posEnd=Access.tellp();
Access.seekg(0,ios::beg);
long posBeg=Access.tellp();
if (posBeg==posEnd){}
else
{
AccessFlightLine();
AccessReserve();
AccessReplace();
}
while(1)
{
switch(MainMenu())
{
case '1':{ReseMenu();break;} //订票办理
case '2':{LogoutMenu();break;} //退票办理
case '3':{LineMenu();break;} //航线管理
case '4':{CustMenu();break;} //乘客管理
case '5':{if(ExitSystem())return;break;} //退出系统与保存
default:{ErrorMess()};
}
}
system("pause");
}