退票

        吃过中午饭,走上了退票的路。在baidu地图上找的路,一个人走了过去,路不远,总的很慢。想着旅游的计划就这么泡了汤,总是不情愿,但也没有办法,一个人坐在东北最便宜的硬座上,想想都没有安全感。
       昨晚在校园里走了半个小时,做出了放弃的决定,希望可以放得下;今天走了一个小时,发现还没有放下,倒是坚定了以后归隐的决心,但是二十年后的事谁说得准呢,就像这次,二天的事说变就变了,世事无常。
 
} void list_menu() { cout<<endl<<""; cout<<endl<<" 菜单"; cout<<endl<<" ************************"; cout<<endl<<" * 0 . 查看排队情况 *"; cout<<endl<<" * 1 . 订票 *"; cout<<endl<<" * 2 . 退票 *"; cout<<endl<<" * 3 . 查看剩余票 *"; cout<<endl<<" * 4 . 查看飞机信息 *"; cout<<endl<<" * 5 . 查看乘客信息 *"; cout<<endl<<" * 6 . 退出 *"; cout<<endl<<" ************************"; void makenull_wait() { wait *tempw; FILE *fp; tempw=new wait; int i; if((fp=fopen("wait.txt","r")) ==NULL ) { fp=fopen("wait.txt","w"); fclose(fp); } wait_end=new wait; wait_head=new wait; wait_end->next=NULL; wait_end->pre=NULL; wait_head=wait_end; wait_head->count=0; fp=fopen("wait.txt","r"); fread(wait_head,sizeof(wait),1,fp); for(i=1;i<=wait_head->count;i++) { fread(tempw,sizeof(wait),1,fp); wait_end->next=tempw; tempw->pre=wait_end; tempw->next=NULL; wait_end=tempw; } } void list_piao() { int i,j; for(i=1;i<=m-1;i++) { if(a[i].seat[0]!=n) { cout<<endl<<"第 "<<i<<" 架飞机剩余的票 :"<<endl; for(j=1;j<=n;j++) if (a[i].seat[j]==0) cout<<" "<<j; cout<<endl; } else cout<<endl<<"The "<<i<<" plane is full !"<<endl<<endl; } } void list_information() { int x; do {cout<<endl<<"显示哪架飞机的信息 ? "; cin>>x;cout<<endl;}while(x<1 || x>=m); cout<<endl<<"第 "<<x<<" 架飞机的信息如下 "<<endl; if(x==1) plane_information(head1); if(x==2) plane_information(head2); if(x==3) plane_information(head3); } void plane_information(node *head) { node *q; char ch; int x=0; if(head!=NULL && head->next!=NULL) q=head->next; else { q=NULL; cout<<"飞机空,无预订票 !"<<endl; } while(q!=NULL) { cout<<endl<<"*******************"<<endl; q->date=q->plane; cout<<"日期 :"<<q->date<<endl; cout<<"座位号 : "<<q->seat<<endl; cout<<"姓名 : "<<q->name; cout<<endl<<"ID 号 : "<<q->id; q=q->next;x++; if (x % 3 ==0) ch=getch(); } cout<<endl; } void book() { int i,j,p; cout<<endl<<"请选择地点:(1、2、3) "; do { cin>>i; if (i<1 || i>=m) { cout<<endl<<"**** 超出范围!****"<<endl<<"请重新输入:"; } else {cout<<endl<<"你要订的是到"<<i<<"地的飞机"<<endl; cout<<endl<<"第 "<<i<<" 架飞机剩余的票 :"<<endl; for(p=1;p<=n;p++) if (a[i].seat[p]==0) cout<<" "<<p; cout<<endl; break;} }while(1); cout<<endl<<"请选择座位号 : "; do { cin>>j; if (j<1 || j>n) { cout<<endl<<"**** 超出范围!****"<<endl<<"请重新输入:"; } else { q->date=i; cout<<endl<<"您的订票日期 : "<<q->date<<endl; break; } }while(1); if (a[i].seat[j]==0) { a[i].seat[j]=1; cout<<endl; a[i].seat[0]++; if(i==1) add_information(head1,1,j); if(i==2) add_information(head2,2,j); if(i==3) add_information(head3,3,j); } else { cout<<endl<<"**** 对不起,该座位已被预订,您被安排到订票等候队列 ****"<<endl; add_wait(i,j); } } void add_wait(int x,int y) { wait *tempw; tempw=new wait; tempw->next=NULL; cout<<"请输入个人信息"<<endl; cout<<endl<<"*************"<<endl; cout<<"姓名 : ";cin>>tempw->name; cout<<"ID号 : ";cin>>tempw->id; cout<<"电话 :";cin>>tempw->phone; tempw->seat=y; tempw->plane=x; wait_end->next=tempw; tempw->pre=wait_end; wait_end=wait_end->next; cout<<endl<<"**** 正在排队等候 ****"<<endl; wait_head->count++; write_to_file(); } void show_wait() { wait *tempw; tempw=wait_head->next; if (tempw==NULL) cout<<endl<<"排队中没有人!"<<endl; while(tempw!=NULL) { cout<<tempw->name<<" - "; tempw=tempw->next; } } void add_information(node *head,int x,int y) { node *temp; temp=new node; temp->pre=NULL; temp->next=NULL; cout<<"请输入个人信息"<<endl; cout<<endl<<"*************"<<endl; cout<<"姓名 : ";cin>>temp->name; cout<<"ID号 : ";cin>>temp->id; temp->seat=y; temp->plane=x; temp->next=head->next; temp->pre=head; if (head->next!=NULL) head->next->pre=temp; head->next=temp; write_to_file(); cout<<endl<<"**** 订票成功 ****"<<endl; } void search_delete(int x) { node *p,*q,*r; wait *tempw,*tempw2,*tempw3; int step=1,t1,t2,i; char ch; p=new node; tempw=new wait; tempw2=new wait; tempw3=new wait; q=head1; cout<<endl<<"请输入个人信息"<<endl; cout<<"*************"<<endl; cout<<endl<<"姓名 : ";cin>>p->name; do{ q=q->next; if ( (q!=NULL) && (comp(q,p)) ) { cout<<endl; q->date=q->plane; cout<<"Located!"<<endl; cout<<"****************"; cout<<endl<<"姓名 : "<<q->name; cout<<endl<<"ID号 : "<<q->id; cout<<endl<<"座位号 : "<<q->seat; cout<<endl<<"班机号 : "<<q->plane; cout<<endl<<"日期 : "<<q->date<<endl; if (x==1) { cout<<"删除该纪录 ? [Y/N] "; cin>>ch; if (ch=='Y' || ch=='y') { t1=q->plane; t2=q->seat; a[t1].seat[t2]=0; a[t1].seat[0]--; r=q;q=q->pre; r->pre->next=r->next; if(r->next!=NULL) r->next->pre=r->pre; delete(r); cout<<"**** 记录删除成功 ! ****"; write_to_file(); tempw=wait_head; for(i=0;i<wait_head->count;i++) { tempw=tempw->next; if(tempw==NULL) break; if((tempw->plane==t1) && (tempw->seat==t2)) { strcpy(tempw3->name,tempw->name); strcpy(tempw3->phone,tempw->phone); cout<<endl<<"等候的人中有可以订票的了:"<<endl; cout<<endl<<"姓名 : "<<tempw->name; cout<<endl<<"ID号 : "<<tempw->id<<endl; a[t1].seat[0]++; a[t1].seat[t2]=1; if(tempw->plane==1) add_information(head1,1,tempw->seat); if(tempw->plane==2) add_information(head2,2,tempw->seat); if(tempw->plane==3) add_information(head3,3,tempw->seat); tempw2=tempw->pre; tempw2->next=tempw->next; if(tempw->next==NULL) wait_end=tempw2; else tempw->next->pre=tempw2; delete(tempw); wait_head->count--; write_to_file(); cout<<endl<<"等候的"<<tempw3->name<<"已经成功订票,已经由电话"<<tempw3->phone<<"通知了"<<endl; break; } } } }continue; } else { if (q==NULL) { step++; if(step==2) q=head2; if(step==3) q=head3; if(step==4) {cout<<endl<<"**** 信息检索完毕 ****";break;}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值