C语言 列车查询系统
#include<iostream>
#include<fstream>
#include<string>
#include<string.h>
using namespace std;
template<class T>
struct Node
{
T data;
Node<T> *next;
};
struct trainxinxi
{
char miaoshu[50];
char trainname[20];
char beginname[20];
char endname[20];
char begintime[20];
char endtime[20];
} ;
template<class T>
class train
{
public:
train(T a[],int n);
void chaxun();
void chaxun2();
void luru();
void xiugai();
void shanchu();
void bianli();
void wenjian();
private:
Node<T> *first;
Node<T> *M;
};
template<class T>
struct Pass
{
T dataplace;
Pass<T> *nextplace;
};
struct byxinxi
{
char placename[20];
char arrive[20];
char go[20];
char length[20];
char sumlength[20];
char time[20];
char sumtime[20];
};
template<class T>
class past
{
public:
past(T a[],int n);
void printlist();
void zhanshanchu();
void zhanluru();
void zhanwenjian();
private:
Pass<T> *first1;
};
byxinxi loc1[4]=
{
{
"渭南","10:00","10:05","200","200","1.0","1.0"},
{
"运城","11:35","11:40","100","300","1.5","2.5"},
{
"石家庄","13:40","14:00","200","500","2.0","4.5"},
{
"北京","16:00","无 ","200","700","2.0","6.5"}
};
byxinxi loc2[4]=
{
{
"郑州","10:00","10:05","200","200","1.0","1.0"},
{
"合肥","12:35","12:40","200","400","2.5","3.5"},
{
"南京","15:40","16:00","250","650","3.0","6.5"},
{
"上海","17:00","无 ","100","750","1.0","7.5"}
};
byxinxi loc3[4]=
{
{
"汉中","9:00","9:05","100","100","0.5","0.5"},
{
"巴中","10:35","10:40","100","200","1.5","2.0"},
{
"南充","11:40","12:00","100","300","0.5","2.5"},
{
"重庆","13:00","无 ","100","400","0.5","3.0"}
};
byxinxi loc4[4]=
{
{
" "," "," "," "," "," "," "},
{
" "," "," "," "," "," "," "},
{
" "," "," "," "," "," "," "},
{
" "," "," "," "," "," "," "}
};
past<byxinxi> B1(loc1,4);
past<byxinxi> B2(loc2,4);
past<byxinxi> B3(loc3,4);
past<byxinxi> B4(loc4,4);
template<class T>
past<T>::past(T a[] ,int n)
{
first1=new Pass<T>;
Pass<T> *r;
r=first1;
for(int i=0;i<=n-1;i++)
{
Pass<T> *s;
s=new Pass<T>;
s->dataplace=a[i];
r->nextplace=s;
r=s;
}
r->nextplace=NULL;
}
template<class T>
void past<T>::zhanluru()
{
Pass<T> *V;
V=first1->nextplace;
int i=1;
while(V!=NULL)
{
char AA[20];
cout<<"请输入第"<<i<<"个途经站: ";
cin>>AA;
strcpy(V->dataplace.placename,AA);
char BB[20];
cout<<"请输入到达时间: ";
cin>>BB;
strcpy(V->dataplace.arrive,BB);
char CC[20];
cout<<"请输入发车时间: ";
cin>>CC;
strcpy(V