⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 return_ticket.cpp

📁 这个是用C++开发的系统,我曾经做的一个数据结构的大作业来的,叫航空订票系统.
💻 CPP
字号:
//return ticket
#include"flight.h"
void airline::return_ticket()//退票
{
	char a[22]; int batnum,realback=0;
    A:cout<<"Welcome to the return_ticket system."<<endl;
    cout<<"Please input the number of tickets that you want to return:"<<endl;
    cin>>batnum;//输入退票数量
if(batnum>0)
{
	custom*t,*fence;
	for(int y=1;y<=batnum;y++)
	{
	fence=t=booked;
    cout<<"Please input your name:"<<endl;
    gets(a);//输入客户名
    while(t!=NULL&&strcmp(a,t->name)!=0)
	{ 
      fence=t;
	  t=t->next;//在航班已订票信息中找寻相应客户资料
	}
	if(t==NULL)//查找客户姓名失败
	{
		cout<<"Your name is not in the booked list,one ticket wasn't returned."<<endl;
	}
	else//办理退票
	{
		if(t==booked)booked=t->next;
		else
		fence->next=t->next;//将客户退票结点除外的链表相接
		delete t;//删除客户订票信息
		realback++;//实际退票数加一
	}
    if(y<batnum)cout<<"Let's go on next return_ticket"<<endl;//继续退票
	else cout<<"The operate is over. Thank you for using."<<endl;//完成退票,退出退票系统
	}
    restTicket+=realback;//将实际退票数加入余票量
}
else {cout<<"Error,please try again."<<endl;goto A;}
}

void airline::back_up(char**k1,char**k2)//补票
{
	custom*p=rest,*t,*fence=p;
	int batnum=restTicket;
	if(batnum>0&&p!=NULL)
	{
      char n;//确认键,存放客户名
	  int cancelnumber=0;//累计补票数
	  int cancelnum;
      cout<<"There are "<<batnum<<" tickets left,you can buy ticket after normal time."<<endl;
	  do{//首先询问排在第一的客户
		  printall(k1,k2);//输出航班信息
        B:cout<<"Please input the number of tickets that you want to buy:"<<endl;
        cin>>cancelnum;//输入客户补票数量
		if(cancelnum>batnum)
		{cout<<"It's not enough ticket for you.\n Do you want to change number(Y/N)?"<<endl; 
		cin>>n;//确认不满足补票数量下修改数量
		if(n=='y'||n=='Y')	goto B;//修改补票数量
		}
		cout<<"The ticket(s) request(s) your demand(Y/N)?"<<endl;
        cin>>n;//输入确认是否满足客户要求
		if(n=='y'||n=='Y')
		{
		  for(int h=0;h<cancelnum;h++)
		  {
			 cout<<"Please input seat number:"<<endl;
			 cin>>p->seat;
			 if(rest==p)rest=p->next;//将P从候补链表中取出
			 else fence->next=p->next;
			 p->next=NULL;
			 t=booked;//先将指针返回到头结点
			 while(t!=NULL&&t->next!=NULL)
			 {
               t=t->next;//找到存在空票的结点
			 }//此时的指针在退票空位的最后结点中,因此需将指针前移
			 if(booked==NULL)booked=p;
			 else t->next=p;//将客户名插入到链表,即退票后余额的位置中
			 p=fence;
		  }
		      cancelnumber+=cancelnum;//计算累计补票数
		  if(p->next!=NULL&&cancelnum<batnum)
		  {
			  fence=p;
			  p=p->next;//或已补票数量仍少于订票,可继续进行补票操作
		  }
		  else break;
		}
		else {fence=p;p=p->next;}
	  //如果排在前面的客户不满足要求,系统进行对下一客户补票的询问工作
	  }while(p!=NULL);
	  cout<<"It's successed in backup ticket,and so for you have backed up "<<cancelnumber<<" tickets"<<endl;
	  //统计已补票数量
	  restTicket-=cancelnumber;
	  cout<<"The operate is over. Thank you for using."<<endl;//完成补票,退出补票系统
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -