您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 机票系统 数据结构
  所属分类: C/C++
  开发工具:
  文件大小: 10kb
  下载次数: 0
  上传时间: 2013-07-02
  提 供 者: u0112*****
 详细说明: #include //#include"ticket.h" #include "string" using namespace std; #define Null 0 //乘客结构体 typedef struct Customer { char Name[10]; int Amount; //订票数 int Level; //舱位等级 int SeatNum; //座位号 char FlightNum[10]; //所定航班号 struct Customer *next; }Customer; //替补乘客结构体 typedef struct Replace { char Name[10]; int Amount; int Level; char FlightNum[10]; //所定航班号 struct Replace *next; }Replace; //Customer *Cusrear; //Replace *Reprear; typedef struct Flight //航线信息 {char Des[10]; //终点站名 char Pla neNum[10]; //航班号 char Week;//飞行周 int Ration;//乘员定额 int FreeTicket; //剩余票数 float Price[3];//舱位等级的价格 int ReplacePas;//候补乘客数 Customer *CustName;//已订票乘客名单 Replace *ReplName;//候补乘客名单 struct Flight *next;//指示下一航线节点 } Flight,*PFlight; //Flight *head;//定义航线头节点 //Flight *rear;//建立航线尾节点 void FlightInsert(Flight *head)//航班添加 { Flight *p; p=new Flight; cout<<"请输入终点站名:"<>p->Des; //cout<<"请输入航班号:"<>p->FlightNum; cout<<"请输入飞机号:"<>p->PlaneNum; cout<<"请输入飞行周:"<>p->Week; cout<<"请输入乘员定额:"<>p->Ration; p->FreeTicket=p->Ration; cout<<"请输入舱位等级的价格:"<>p->Price[0]; cout<<"请输入普通舱价格:"<>p->Price[1]; cout<<"请输入经济舱价格:"<>p->Price[2]; p->ReplName=new Replace; p->CustName=new Customer; p->CustName->next=Null; p->ReplName->next=Null; p->ReplacePas=0; p->next=head->next; head->next=p; //rear->next=p;// 利用尾指针便于航班的添加 //rear=p; //rear->next=Null; } void FlightSearch(Flight *head)//查询航班 { Flight *p,*q; char FlightNum[10]; int i=0; while (i!=1) {cout<<"请输入需要查询的航班号:"<>FlightNum; p=head; while(p->next&&strcmp(p->next->PlaneNum,FlightNum)) { p=p->next; } q=p->next; if(q==Null) {cout<<"对不起不存在该航班"<PlaneNum<Des<Week<Ration<FreeTicket<ReplacePas<Price[0]<Price[1]<Price[0]<>i; } } void FlightRework(Flight *head)//修改航班信息 { int Customer_Number; Flight *p,*q; char FlightNum[10]; char i='0'; p=head; cout<<"请输入需要修改的航班号:"<>FlightNum; while(p->next&&strcmp(p->next->PlaneNum,FlightNum)) {p=p->next;} q=p->next; if (q==Null) { cout<<"对不起不存在此航班"<>i; switch(i) {case '1':cout<<"请输入航班号:"<>q->PlaneNum;break; case '2':cout<<"请输入目的地:"<>q->Des;break; case '3':cout<<"请输入航班号飞行周:"<>q->Week;break; case '4':cout<<"请输入乘员定额:"<Ration-q->FreeTicket; cin>>q->Ration; q->FreeTicket=q->Ration-Customer_Number;break; case '5':cout<<"请输入头等舱价格:"<>q->Price[0];break; case '6':cout<<"请输入普通舱价格:"<>q->Price[1];break; case '7':cout<<"请输入经济舱价格:"<>q->Price[2];break; case '8':break; default:cout<<"error\n";break; } } } } void FlightDelete(Flight *head) //利用表头指针定位要删除的航班信息 { Flight *p,*q; char FlightNum[10]; int i=0; while(i!=1) {cout<<"请输入需要删除的航班号:"<>FlightNum; p=head; while(p->next&&strcmp(p->next->PlaneNum,FlightNum)) {p=p->next;} q=p->next; if(q!=Null) { // if(q->next==Null) // {rear=p;} p->next=p->next->next; delete q;} else {cout<<"你所要删除的航班不存在"<>i; } } void FlightBuyTicket(Flight *head)//订票 { int Ticket_Amount; void BuyTicket(Flight *,int); void Buyreplace(Flight *,int,int); Flight *p,*q; char Des[10]; int i=2; while(i!=1) {cout<<"请输入目的地:"<>Des; p=head; while(p->next&&strcmp(p->next->Des,Des)) {p=p->next; } q=p->next; if (q==Null) {cout<<"对不起不存在此航班"<>Ticket_Amount; while(Ticket_Amount==0) { cout<<"请输入一个非零数"<>Ticket_Amount; } if(Ticket_Amount<=q->FreeTicket) {BuyTicket(q,Ticket_Amount);}//买票 else {int n; cout<<"剩余票数小于订票数,是否需要列入候补名单?(1、是 2、否)"<>n; Buyreplace(q,Ticket_Amount,n);//进入替补名单 } cout<<"1、返回菜单 2、继续"<>i; } } } } void BuyTicket(Flight *q, int Ticket_Amount)//买票 {int n=Ticket_Amount; Customer *Cus2,*Cusrear; Cus2=new Customer; Cus2->SeatNum=q->Ration-q->FreeTicket+1; strcpy(Cus2->FlightNum,q->PlaneNum); Cus2->Amount=Ticket_Amount; cout<<"请输入姓名:"<>Cus2->Name; cout<<"请输入舱位等级(1-3)"<>Cus2->Level; cout<<"你的座位号为:"<SeatNum++<<" "; } cout<CustName->next==Null) { Cusrear=q->CustName; Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=Null; } else{ Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=Null; } q->FreeTicket-=Ticket_Amount; } void Buyreplace(Flight *q,int Ticket_Amount,int n)//进入替补队列 {Replace *Rep2,*Reprear; Rep2=new Replace; if(n==1) { q->ReplacePas+=Ticket_Amount; strcpy(Rep2->FlightNum,q->PlaneNum); Rep2->Amount=Ticket_Amount; cout<<"请输入姓名:"<>Rep2->Name; cout<<"请输入舱位等级(1-3)"<>Rep2->Level; if(q->ReplName->next==Null) {Reprear=q->ReplName; Reprear->next=Rep2; Reprear=Rep2; Reprear->next=Null; } else{ Reprear->next=Rep2; Reprear=Rep2; Reprear->next=Null; } } } void FlightCancelTicket(Flight *head)//退票 { //void BuyTicket(Flight,int); Flight *q,*p; Customer *h,*j,*Cusrear; Customer *Cus2; Replace *rep; char FlightNum[10]; char Customer_Name[10]; int Replace_Amount;//候补第一个人的订票数 int i=0; while(i!=1) { cout<<"请输入要退订的航班号:"<>FlightNum; p=head; while(p->next&&strcmp(p->next->PlaneNum,FlightNum)) { p=p->next; } q=p->next; if(q==NULL) {cout<<"对不起不存在次航班"<>Customer_Name; h=q->CustName; while(h->next&&strcmp(h->next->Name,Customer_Name)) {h=h->next;} j=h->next; if(j==NULL) { cout<<"查无此人"<next==NULL)//当删除最后一个节点 Cusrear=h; h->next=h->next->next; q->FreeTicket+=j->Amount; delete j; cout<<"删除成功!"<ReplName->next!=NULL) { Replace_Amount=q->ReplName->next->Amount; if(Replace_Amount<=q->FreeTicket) { rep=q->ReplName->next; Cus2=new Customer; Cus2->SeatNum=q->Ration-q->FreeTicket+1; strcpy(Cus2->FlightNum,q->PlaneNum); strcpy(Cus2->Name,rep->Name); Cus2->Amount=rep->Amount; Cus2->Level=rep->Level; cout<<"乘客"<Name<<"已经成功买票"<Amount);i++) { cout<SeatNum++<<" "; } cout<CustName->next==Null) //把等候队列中的乘客加入到已经订票的乘客队列中 { Cusrear=q->CustName; Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=Null; } else { Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=Null; } q->FreeTicket-=rep->Amount; q->ReplName->next=q->ReplName->next->next; q->ReplacePas--; delete rep; } cout<<"2 退出姓名录入"<>i; } } cout<<"1 返回主菜单"<>i; } } void main() { Flight *head,*rear; head=rear=new Flight; head->next=Null; rear->next=Null; char i='0'; while(i!='7') { cout<<"********航空订票系统*********"<>i; switch(i) {case '1': FlightInsert(head );break; case '2': FlightSearch(head);break; case '3': FlightRework(head);break; case '4': FlightDelete(head);break; case '5': FlightBuyTicket(head);break; case '6': FlightCancelTicket(head);break; case '7':break; default:cout<<"error\n";break; } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 机票
 输入关键字,在本站1000多万海量源码库中尽情搜索: