课程设计要求:
一交通公司,班车系统的数据包括如下两部分:
①班车信息:班交及车号、最大载客数、起点、开车时间、终地点、到达终点站时间,单价;
② 乘客信息:车次及车号、身份证号码、姓名、性别、出生年月、座位号。
乘客订票的主要方式是:乘客提供起点、时间、终点、订票数等订票要求,根据事先保存的班数据决定乘客能否订票?只有全部满足了乘客的订票要求并且所订班次有足够的未订座位之后才能完成订票处理,并且修改该班次的未订座位数(每个班的未订座位数的初始值就是该班次的最大载客数);否则,订票失败,并且给出不能订票的原因。
功能要求 :
⑴ 增加班次记录。
⑵ 班次取消。
⑶ 班次查询。
⑷ 班次订票。
⑸ 设计一个菜单,至少具有上述操作要求的基本功能。
程序:
</pre></p><pre name="code" class="cpp">// kcsjbcxxcx.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
//#include<dos.h>
//#include<time.h>
using namespace std;
int n=0,m=0;
struct date
{
int year;
int month;
int day;
};
struct time
{
int shi;
int fen;
int miao;
};
struct guanli
{
char zh[15];
char mima[20];
}guan1={"zd1123xufei","201211632326"},guan2={"minggezhijia","zd2012cjjxx"};
enum beiz
{
售票中,可发车,班次取消};
enum qid
{湛江};
enum zhongd
{广州,深圳,东莞,佛山,揭阳,中山,茂名,汕头};
struct banche
{
int bianhao; //编号
enum qid qidian; //出发地
enum zhongd zhongdian; //终点站
int zuoweishu; //最大载客量
int shengyup; //剩余可载客数
struct time fache; //发车时间
enum beiz beizhu; //备注信息:是否可购票和发车
banche *next;
};
struct dingpiaoxx
{
char xingming[30];
char zheng[19];
enum zhongd gpzd;
struct time shijian;
struct date riqi;
int piaoshu;
dingpiaoxx *NEXT;
};
banche *creat();
banche *insert(banche *head,banche *banc);
banche *charu(banche *hea);
void xiug(banche *hed);
banche *del(banche *head);
void chache(banche *head);
dingpiaoxx *CREAT();
dingpiaoxx *dingpiao(dingpiaoxx *HEAD);
void gaip(dingpiaoxx *HEAD);
void xiup(dingpiaoxx *HED );
void chapiao(dingpiaoxx *HEAD );
dingpiaoxx *tianjia(dingpiaoxx *HEAD);
dingpiaoxx *shanc(dingpiaoxx *HEAD );
void welc();
//void chushi();
void xuanze();
void weihu();
void kehu();
int denglu();
/*********************下面是主函数******************/
int main()
{
char key='y';
welc();
//chushi();
while(key!='n'&&key!='N')
{
xuanze();
int a,b;
cin>>a;
if(a==1)
{
b=denglu();
if(b==1)
{int gg=1;
while(gg=1)
{weihu();
cout<<"是否继续?1:是 , 2:否 "<<endl;
cin>>gg;
}}
}
else if(a==2)
{
{int gg=1;
while(gg=1)
{kehu();
cout<<"是否继续?1:是 , 2:否 "<<endl;
cin>>gg;
}}
}
else
cout<<"输入错误,请按提示信息输入!"<<endl;
cout<<"感谢你使用本系统"<<endl
<<"按“Y”返回身份选择界面"<<endl
<<"按“N”退出本系统"<<endl;
cin>>key;
}
return 0;
}
/********************************以下是实现各种功能的函数******************/
banche *head=creat();
banche *creat() //建立班次信息表
{
int a,b=1;
char key;
banche *head,*p1,*p2;
head=NULL;
p1=new(banche);
p2=p1;
cout<<"请输入班车编号"<<endl;
cin>>p1->bianhao;
p1->qidian=qid(0);
cout<<"请输入班车到达的终点站对应的序号"<<endl
<<"0 广州;1 深圳;2 东莞;3 佛山;4 揭阳;5 中山;6 茂名;7 汕头"<<endl;
cin>>a;
p1->zhongdian=zhongd(a);
cout<<"请输入该班次最大乘客数"<<endl;
cin>>p1->zuoweishu;
p1->shengyup = p1->zuoweishu;
cout<<"请输入班车出发时间(时、分)"<<endl;
cin>>p1->fache.shi >>p1->fache.fen ;
p1->beizhu =beiz(0);
while(b==1)
{
n++;
if(n==1)
head=p1;
else
{
p2->next=p1;
p2=p1;
}
p1=new(banche);
cout<<"请输入班车编号"<<endl;
cin>>p1->bianhao;
p1->qidian=qid(0);
cout<<"请输入班车到达的终点站对应的序号"<<endl
<<"0 广州;1 深圳;2 东莞;3 佛山;4 揭阳;5 中山;6 茂名;7 汕头"<<endl;
cin>>a;
p1->zhongdian=zhongd(a);
cout<<"请输入该班次最大乘客数"<<endl;
cin>>p1->zuoweishu;
p1->shengyup = p1->zuoweishu;
p1->beizhu =beiz(0);
cout<<"请输入班车出发时间(时、分)"<<endl;
cin>>p1->fache.shi >>p