#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <fstream>
using namespace std;
#define MAXSIZE 9
/*定义航线量的最大值*/
typedef struct ads{
char Enternum[7];
char name[100];
char sex[2];
int age;
char key[10];
}ad;
typedef struct cms{
char EnterNum[8]; //登入账号
char name[100]; //姓名
char sex[2]; //性别
int age; //年龄
char key[10]; //登入密码
}com;
typedef struct numbers{
int comnum;//用户人数
int adnum; //管理员人数;
}number;
typedef struct IDNode
{
char ID[18];
struct IDNode *next;
}IDList;
typedef struct wat_ros
{
char name[10];/*姓名*/
char ID[18];/*身份证号*/
int req_amt;/*订票量*/
struct wat_ros *next;
}qnode,*qptr;
typedef struct pqueue
{
qptr front;/*等候替补客户名单域的头指针*/
qptr rear;/*等候替补客户名单域的属指针*/
}linkqueue;
typedef struct ord_ros
{
char name[10];/*客户姓名*/
char ID[18];/*身份证号*/
int ord_amt;/*订票量*/
int grade;/*舱位等级*/
struct ord_ros *next;
}linklist;
struct airline
{
char ter_name[10];/*终点站名 */
char air_num[10];/*航班号*/
char plane_num[10];/*飞机号*/
char date[7];/*飞行日期(星期几)*/
int tkt_amt;/*乘员定额*/
int tkt_sur;/*余票量*/
linklist *order;
/*乘员名单域,指向乘员名单链表的头指针*/
linkqueue wait;
/*等候替补的客户名单域,分别指向排队等候名单队头队尾的指针*/
}lineinfo;
struct airline *start;
struct airline air[MAXSIZE];
void insert()
{
char NG;
fstream file;
file.open("airline.txt",ios::trunc);
int i=0;
do{
cout<<"请输入航班"<<i+1<<"信息(共"<<MAXSIZE<<"条)"<<endl;
cout<<"请输入终点站名字:"<<endl;
cin>>(air+i)->ter_name;
cout<<"请输入航班号:"<<endl;
cin>>(air+i)->air_num;
cout<<"请输入飞机号:"<<endl;
cin>>(air+i)->plane_num;
cout<<"请输入飞行日期:"<<endl;
cin>>(air+i)->date;
cout<<"请输入乘员定额:"<<endl;
cin>>(air+i)->tkt_amt;
cout<<"请输入余票量:"<<endl;
cin>>(air+i)->tkt_sur;
//文件操作
//写入!
file<<(air+i)->ter_name<<" "<<(air+i)->air_num<<" "<<(air+i)->plane_num<<" "<<(air+i)->date
<<" "<<(air+i)->tkt_amt<<" "<<(air+i)->tkt_sur<<endl;
/*cin>>(air+i)->ter_name>>(air+i)->air_num>>(air+i)->plane_num>>(air+i)->date>>(air+i)->tkt_amt>>(air+i)->tkt_sur;*/
printf("还需要继续添加吗?(Y,y/N,n)\n");
cin>>NG;
}while((NG=='Y'||NG=='y')&&(i++<=MAXSIZE));
}
void display(struct airline *info)
/*打印每条航线的基本信息*/
{
printf("│ %-6.6s │ %-6.6s │ %-6.6s│ %-6.6s │ %-6.0d │ %-6.0d │\n",info->ter_name,info->air_num,info->plane_num,info->date,info->tkt_amt,info->tkt_sur);
}
void list()
/*打印全部航线信息*/
{
struct airline *info;
int i=0;
info=air;
cout<<"┌────┬────┬────┬─────┬─────┬─────┐"<<endl;
cout<<"│终点站名│ 航班号 │飞机号 │飞行日期 │ 乘员定额 │ 余票量 │"<<endl;
cout<<"├────┼────┼────┼─────┼─────┼─────┤"<<endl;
while(i<MAXSIZE)
{
display(info);
if(i!=MAXSIZE-1)
printf("├────┼────┼────┼─────┼─────┼─────┤\n");
info++;
i++;
}
cout<<"└────┴────┴────┴─────┴─────┴─────┘\n";
printf("\n\n");
}
void search()
/*根据客户提出的终点站名输出航线信息*/
{
struct airline *info,*find();
char name[10];
int i=0;
info=start;
cout<<"请输入终点站名:"<<endl;
cin>>name;
while(i<MAXSIZE)
{
if(!strcmp(name,info->ter_name)) break;
info++;
i++;
}
if(i>=MAXSIZE)
cout<<"对不起,该航线未找到!"<<endl;
else
{
cout<<"终点站名"<<" "<<"航班号"<<" "<<"飞机号"<<" "<<"飞行日期"<<" "<<"成员定额"<<" "<<"余票量"<<endl;
display(info);
}
}
struct airline *find()
/*根据系统提出的航班号查询并以指针形式返回*/
{ struct airline *info;
char number[10];
int i=0;
info=start;
cout<<"请输入航班号:"<<endl;
cin>>number;
while(i<MAXSIZE)
{
if(!strcmp(number,info->air_num)) return info;
info++;
i++;
}
cout<<"对不起,该航线未找到!"<<endl;
return NULL;
}
void prtlink()
/*打印订票乘员名单域的客户名单信息*/
{
linklist *p;
struct airline *info;
info=find();
p=info->order;
if(p!=NULL)
{
cout<<"客户姓名 身份证号 订票数额 舱位等级"<<endl;
while(p)
{
cout<<p->name<<" "<<p->ID<<" "<<p->ord_amt<<" "<<p->grade<<endl;
p=p->next;
}
}
else
{
cout<<"该航线没有客户信息!"<<endl;
}
}
linklist *insertlink(linklist *head,int amount,char name[],char ID[],int grade)
/*增加订票乘员名单域的客户信息*/
{
linklist *p1,*new1;
p1=head;
new1=(linklist *)malloc(sizeof(linklist));
if(!new1)
{
cout<<"Out of memory!!"<<endl;
return NULL;
}
strcpy(new1->name,name);
strcpy(new1->ID,ID);
new1->ord_amt=amount;
new1->grade=grade;
new1->next=NULL;
if(head==NULL)
/*若原无订票客户信息*/
{
head=new1;
new1->next=NULL;
}
else
{
head=new1;
new1->next=p1;
}
return head;
}
linkqueue appendqueue(linkqueue q,char name[],int amount)
/*增加排队等候的客户名单域*/
{
qptr new1;
new1=(qptr)malloc(sizeof(qnode));
strcpy(new1->name,name);
new1->req_amt=amount;
new1->next=NULL;
if(q.front==NULL)
/*若原排队等候客户名单域为空*/
{
q.front=new1;
}
else
{
q.rear->next=new1;
}
q.rear=new1;
return q;
}
void order()
/*办理订票业务*/
{
struct airline *info;
IDList * L,*temp1,*temp2;
int amount,grade,i;
char name[10];
char ID[18];
info=start;
if(!(info=find()))
{
return;
}
/*根据客户提供的航班号进行查询,如为空,退出该模块*/
cout<<"请输入你订票所需要的数量:"<<endl;
scanf("%d",&amount);
if(amount>info->tkt_sur)/*若客户订票额超过乘员定票总额,要求用户选择*/
{
cout<<"对不起,您输入的票的数量已经超过余票定额!"<<endl;
cout<<"输入 1 ,预定所有"<<info->tkt_sur<<"张剩余机票 ,输入 2 返回!"<<endl;
char a;
cin>>a;
L=(IDList *)malloc(sizeof(IDList));
L->next=NULL;
temp1=L;
for(i=0;i<info->tkt_sur;i++)
{
if(a=='1')
{
int i;
cout<<"请输入您的姓名(订票客户):"<<endl;
cin>>name;
cout<<"请输入您的身份证号码:"<<endl;
cin>>ID;
while( strlen(ID)!=18 )
/*检查身份证号长度*/
{
ID[18]=0;
cout<<"您输入的身份证号长度错误"<<" "<<ID<<endl;
cout<<"请重新输入您的身份证号码:"<<endl;
cin>>ID;
}
temp1=L;
while(temp1->next!=NULL&&strcmp(ID,temp1->ID)!=0)
temp1=temp1->next;
if(strcmp(ID,temp1->ID)==0)
{
printf("您的身份证已经领过余票!\n");
break;
}
else
{
temp2=(IDList *)malloc(sizeof(IDList));
temp2->next=temp1->next;
temp1->next=temp2;
}
cout<<"请输入"<<name<<":票的舱位等级:"<<endl;
cin>>grade;
info->order=insertlink(info->order,amount,name,ID,grade);/*在订票乘员名单域中添加客户信息*/
for(i=0;i<amount;i++)/*依次输出该订票客户的座位号*/
{
cout<<name<<"的座位号是:"<<info->tkt_amt-info->tkt_sur+i+1<<endl;
}
info->tkt_sur-=amount;/*该航线的余票量应减掉该客户的订票量*/
printf("\n祝您乘坐愉快!\n");
}
else
{
return;
}
}
}
if(amount<=info->tkt_sur)
/*若客户订票额末超过余票量,订票成功并等记信息*/
{
int i;
L=(IDList *)malloc(sizeof(IDList));
L->next=NULL;
temp1=L;
for(i=0;i<amount;i++)
{
cout<<"请输入您的姓名(订票客户):"<<endl;
cin>>name;
cout<<"请输入您的身份证号码:"<<endl;
cin>>ID;
while( strlen(ID)!=18 )
/*检查身份证号长度*/
{
ID[18]=0;
cout<<"您输入的身份证号长度错误"<<" "<<ID<<endl;
cout<<"请重新输入您的身份证号码:"<<endl;
cin>>ID;
}
temp1=L;
while(temp1->next!=NULL&&strcmp(ID,temp1->ID)!=0)
temp1=temp1->next;
if(strcmp(ID,temp1->ID)==0)
没有合适的资源?快使用搜索试试~ 我知道了~
c++ 飞机订票系统设计及分析(包含源代码和设计报告书)
共2个文件
doc:1个
cpp:1个
5星 · 超过95%的资源 需积分: 50 202 下载量 2 浏览量
2010-11-16
14:58:12
上传
评论 46
收藏 370KB RAR 举报
温馨提示
飞机订票系统,可以实现订票、退票、查看航班信息、查看已订票的乘客信息等功能。 各模块的要求: (1)录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定) (2)查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);输入起飞抵达城市,查询飞机航班情况。 (3)订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班。 (4)退票: 可退票,退票后修改相关数据文件。; (5)客户资料包括:姓名,证件号,订票数量及航班情况,订单要有编号。 (6)修改航班信息:当航班信息改变时,可以修改航班数据文件。
资源推荐
资源详情
资源评论
收起资源包目录
飞机订票系统.rar (2个子文件)
飞机订票系统
dfsd11333.cpp 27KB
2010暑期实训报告书.doc 772KB
共 2 条
- 1
bubble0528
- 粉丝: 5
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页