C++实现汽车订票系统(C++课程设计)
[html]
#include<iostream>
#include<fstream>
#include<cstring>
#include<iomanip>
#define Maxsize 100
using namespace std;
struct Route
{
char number[20];
char startandreach[20];
char type[20];
char longroute[20];
char time[20];
double price;
int sitnumber;
int save;
int sale;
};
struct Ticketnews
{
char type[20];
char time[20];
int booked;
int remained;
};
struct Booknews
{
char name[20];
char identitycard[20];
char number[20];
char date[20];
char road[20];
int sitnumber;
};
void Match(Route L1[],Ticketnews L2[],int n)//票务信息保存
{
ofstream outfile("票务信息.txt",ios::out);
if (!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
int i;
for(i=0;i<n;i++)
{
strcpy(L2[i].type,L1[i].type);
strcpy(L2[i].time,L1[i].time);
L2[i].booked=L1[i].sale;
L2[i].remained=L1[i].save;
outfile<<L2[i].type<<" "<<L2[i].time<<" "<<L2[i].booked<<" "<<L2[i].remained<<endl;
}
outfile.close();
}
int Book(Booknews &L1,Route &L2,int s)//这里一定要是参数传递
{
ofstream outfile("买票客户信息.txt",ios::app);//怎么可以重复的写入订票人的数据
if (!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
cout<<"请输入订票信息:"<<endl;
cout<<"姓名:";cin>>L1.name;
cout<<"身份证:";cin>>L1.identitycard;
cout<<"车次:";cin>>L1.number;
cout<<"日期:";cin>>L1.date;
cout<<"路线:";cin>>L1.road;
L2.sale++;
L2.save--;
L1.sitnumber=L2.sale;
cout<<"订票信息为:"<<endl;
cout<<"姓名:"<<L1.name<<endl<<"身份证:"<<L1.identitycard<<endl<<"车次:"<<L1.number<<endl<<"日期:"<<L1.date<<endl<<"座位号:"<<L1.sitnumber<<endl<<"路线:"<<L1.road<<endl;
outfile<<L1.name<<" "<<L1.identitycard<<" "<<L1.number<<" "<<L1.date<<" "<<L1.sitnumber<<" "<<L1.road<<endl;
outfile.close();
s++;
return s;
}
int Return(Booknews L1[],int s)
{
Booknews L;
con:cout<<"请输入退票者姓名,身份证";
cin>>L.name>>L.identitycard;
int i;
for(i=0;i<s;i++)
{
if(((strcmp(L.name,L1[i].name))&&(strcmp(L.identitycard,L1[i].identitycard))))
{
cout<<"这个人没有订票!"<<endl;
return 0;
}
else
{
int j=i;
cout<<"该订票者的信息为:";
cout<<"姓名:"<<L1[i].name<<endl;
cout<<"身份证:"<<L1[i].identitycard<<endl;
cout<<"车次:"<<L1[i].number<<endl;
cout<<"订票日期:"<<L1[i].date<<endl;
cout<<"座位号:"<<L1[i].sitnumber<<endl;
cout<<"路线:"<<L1[i].road<<endl;
cout<<"以上信息是否符合?符合请按1,不符合请按2:";
int k;
cin>>k;
if(k==2) goto con;
else
/*cout<<"输入订票者的车次,座位号和日期:";
cin>>L.number>>L.sitnumber>>L.date;
for(i=L.sitnumber-1;i<s;i++)
{
strcpy(L1[i].name,L1[i+1].name);
strcpy(L1[i].identitycard,L1[i+1].identitycard);
strcpy(L1[i].number,L1[i+1].number);
strcpy(L1[i].date,L1[i+1].date);
L1[i].sitnumber=L1[i+1].sitnumber;
&nbs
补充:软件开发 , C++ ,