书接上回
12.main.h
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<time.h>
#include<windows.h>
#include<fstream>
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
int person::totalpassenger=0;//预测功能中的每天乘客数量
int person::yucepassenger[6]={0};//预测乘客量 7-9 9-11 11-13 13-18 18-20 20-23 专门用来记录历史数据
int person::yucetotalpassenger=0;//当前乘车人数
int person::yonghupassenger[3] = { 0 };
int person::yonghuzongpassenger = 0;
double car::fachetime = 0;
double ticket::totalprice = 0;
int common::n = 0;//普通用户数目 //地铁站工作人员密码为139780 账户名为xxz
int month::n1 = 0;//月卡用户数目
int year::n2 = 0;//年卡用户数目
int car::car111 = 0;//1号线总车次 D110 D111 D112 D113 D114
int car::car222 = 0;//2号线总车次 D105 D106 D107 D108 D109
int car::car333 = 0;//3号线总车次 D100 D101 D102 D103 D104
string road1::station[100] = {
/*1号线开始*/"迈皋桥"/*1*/, "红山动物园"/*2*/,"火车站"/*3*/,"新模范马路"/*4*/,"中南大学"/*5*/,"鼓楼"/*6*/,"珠江路"/*7*/,
"新街口"/*8*/,"张府园"/*9*/,"三山街"/*10*/,"中华门"/*11*/,"安德门"/*12*/,"小行"/*13*/,"中胜"/*14*/,"元通"/*15*/,"奥体中心"/*16*/,
/*2号线开始*/"油坊桥"/*17*/,"雨润大桥"/*18*/,"奥体东"/*19*/,"兴隆大桥"/*20*/,"集庆门大桥"/*21*/,"云锦路"/*22*/,
"莫愁湖"/*23*/,"汉中门"/*24*/,"上海路"/*25*/,"大行宫"/*26*/,"西安门"/*27*/,"明故宫"/*28*/,"苜蓿园"/*29*/,"下马坊"/*30*/,"孝陵卫"/*31*/,
"钟灵街"/*32*/,"马群"/*33*/,"金马路"/*34*/,"仙鹤门"/*35*/,"学则路"/*36*/,"仙林中心"/*37*/,"羊山公园"/*38*/,"南大仙林校区"/*39*/,"经天路"/*40*/,
/*3号线开始*/"天隆寺"/*41*/,"软件大道"/*42*/,"花神庙"/*43*/,"火车南站"/*44*/,"双龙大道"/*45*/,"河定桥"/*46*/,"胜太路"/*47*/,
"百家湖"/*48*/,"小龙湾"/*49*/,"竹山路"/*50*/,"天印大道"/*51*/,"龙眠大道"/*52*/,"南医大"/*53*/,"交通学院"/*54*/,"药科大学"/*55*/ };
int road1::stationnumber[100] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55 };
int road1::stationxian[6] = { 1,16,17,40,41,55 };
int road1::stationhuancheng[3] = { 8,12,15 };
int transform(string c)//站点名称转站点编号
{
int i;
for(i=1;i<=38;i++)
if(road1::station[i-1]==c)
return i;
return -1;
}
void GotoXY(int x,int y)
{
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X=x;
pos.Y=y;
SetConsoleCursorPosition(hout,pos);
}
void road1::showroad()
{
//SetConsoleTextAttribute(hout,0x0E);//亮黄色
//GotoXY(0,0);cout<<"〖中南地铁运营线路图〗";
//画一号线路图
SetConsoleTextAttribute(hout,0x0A);//亮绿色
GotoXY(35,32);cout<<"中南地铁一号线";
GotoXY(40,0);cout<<"⊙奥体中心";
GotoXY(40,1);cout<<"┃";
SetConsoleTextAttribute(hout,0xE9);
GotoXY(40,2);cout<<"●元通";
SetConsoleTextAttribute(hout,0x0A);
GotoXY(40,3);cout<<"┃";
GotoXY(40,4);cout<<"⊙中胜";
GotoXY(40,5);cout<<"┃";
GotoXY(40,6);cout<<"⊙小行";
GotoXY(40,7);cout<<"┃";
SetConsoleTextAttribute(hout,0xB9);
GotoXY(40,8);cout<<"◆安德门";
SetConsoleTextAttribute(hout,0x0A);
GotoXY(40,9);cout<<"┃";
GotoXY(40,10);cout<<"⊙中华门";
GotoXY(40,11);cout<<"┃";
GotoXY(40,12);cout<<"⊙三山街";
GotoXY(40,13);cout<<"┃";
GotoXY(40,14);cout<<"⊙张府园";
GotoXY(40,15);cout<<"┃";
SetConsoleTextAttribute(hout,0xE9);
GotoXY(40,16);cout<<"●新街口";
SetConsoleTextAttribute(hout,0x0A);
GotoXY(40,17);cout<<"┃";
GotoXY(40,18);cout<<"⊙珠江路";
GotoXY(40,19);cout<<"┃";
GotoXY(40,20);cout<<"⊙鼓楼";
GotoXY(40,21);cout<<"┃";
GotoXY(40,22);cout<<"⊙玄武门";
GotoXY(40,23);cout<<"┃";
GotoXY(40,24);cout<<"⊙新模范马路";
GotoXY(40,25);cout<<"┃";
GotoXY(40,26);cout<<"⊙火车站";
GotoXY(40,27);cout<<"┃";
GotoXY(40,28);cout<<"⊙红山动物园";
GotoXY(40,29);cout<<"┃";
GotoXY(40,30);cout<<"⊙迈皋桥";
/*三号线*/
SetConsoleTextAttribute(hout,0x0E);//亮黄色
GotoXY(3,7);cout<<"中南地铁三号线";
GotoXY(2,8);cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━";
GotoXY(2,9);cout<<"⊙天隆寺";
GotoXY(2,10);cout<<"┃";
GotoXY(2,11);cout<<"⊙软件大道";
GotoXY(2,12);cout<<"┃";
GotoXY(2,13);cout<<"⊙花神庙";
GotoXY(2,14);cout<<"┃";
GotoXY(2,15);cout<<"⊙火车南站";
GotoXY(2,16);cout<<"┃";
GotoXY(2,17);cout<<"⊙双龙大道";
GotoXY(2,18);cout<<"┃";
GotoXY(2,19);cout<<"⊙河定桥";
GotoXY(2,20);cout<<"┃";
GotoXY(2,21);cout<<"⊙胜太路";
GotoXY(2,22);cout<<"┃";
GotoXY(2,23);cout<<"⊙百家湖";
GotoXY(2,24);cout<<"┃";
GotoXY(2,25);cout<<"⊙小龙湾";
GotoXY(2,26);cout<<"┃";
GotoXY(2,27);cout<<"⊙竹山路";
GotoXY(2,28);cout<<"┃";
GotoXY(2,29);cout<<"⊙天印大道";
GotoXY(2,30);cout<<"┃";
GotoXY(2,31);cout<<"⊙龙眠大道";
GotoXY(2,32);cout<<"┃";
GotoXY(2,33);cout<<"⊙南医大";
GotoXY(2,34);cout<<"┃";
GotoXY(2,35);cout<<"⊙交通学院";
GotoXY(2,36);cout<<"┃";
GotoXY(2,37);cout<<"⊙药科大学";
//画二号线路图
SetConsoleTextAttribute(hout,0x0C);//亮红色
GotoXY(60,0);cout<<"中南地铁二号线";
GotoXY(38,2);cout<<"━━";
GotoXY(28,2);cout<<"⊙雨润大街";
GotoXY(26,2);cout<<"━";
GotoXY(18,2);cout<<"⊙油坊桥";
GotoXY(46,2);cout<<"━━━━━━━━━━━━━━";
GotoXY(60,2);cout<<"┓";
GotoXY(60,3);cout<<"⊙奥体东";
GotoXY(60,4);cout<<"┃";
GotoXY(60,5);cout<<"⊙兴隆大街";
GotoXY(60,6);cout<<"┃";
GotoXY(60,7);cout<<"⊙集庆门大桥";
GotoXY(60,8);cout<<"┃";
GotoXY(60,9);cout<<"⊙云锦路";
GotoXY(60,10);cout<<"┃";
GotoXY(60,11);cout<<"⊙莫愁湖";
GotoXY(60,12);cout<<"┃";
GotoXY(60,13);cout<<"⊙汉中门";
GotoXY(60,14);cout<<"┃";
GotoXY(60,15);cout<<"⊙上海路";
GotoXY(48,16);cout<<"━━━━━━━━━━━━┛";
GotoXY(20,16);cout<<"┏━━━━━━━━━━━━━━━━━━━";
GotoXY(20,17);cout<<"⊙大行宫";
GotoXY(20,18);cout<<"┃";
GotoXY(20,19);cout<<"⊙西安门";
GotoXY(20,20);cout<<"┃";
GotoXY(20,21);cout<<"⊙明故宫";
GotoXY(20,22);cout<<"┃";
GotoXY(20,23);cout<<"⊙苜蓿园";
GotoXY(20,24);cout<<"┃";
GotoXY(20,25);cout<<"⊙下马坊";
GotoXY(20,26);cout<<"┃";
GotoXY(20,27);cout<<"⊙孝陵卫";
GotoXY(20,28);cout<<"┃";
GotoXY(20,29);cout<<"⊙钟灵街";
GotoXY(20,30);cout<<"┃";
GotoXY(20,31);cout<<"⊙马群";
GotoXY(20,32);cout<<"┃";
GotoXY(20,33);cout<<"⊙金马路";
GotoXY(20,34);cout<<"┃";
GotoXY(20,35);cout<<"⊙仙鹤门";
GotoXY(20,36);cout<<"┃";
GotoXY(20,37);cout<<"┗";
GotoXY(22,37);cout<<"⊙学则路";
GotoXY(30,37);cout<<"━";
GotoXY(32,37);cout<<"⊙仙林中心";
GotoXY(42,37);cout<<"━";
GotoXY(44,37);cout<<"⊙羊山公园";
GotoXY(54,37);cout<<"━";
GotoXY(56,37);cout<<"⊙南大仙林校区";
GotoXY(70,37);cout<<"━";
GotoXY(72,37);cout<<"⊙经天路";
SetConsoleTextAttribute(hout,15);
GotoXY(90,3);cout<<"注意:1~8站:2元 9~12站:3元";
GotoXY(90,5);cout<<" 12站以上:4元";
GotoXY(90,19);cout<<"欢迎乘坐中南地铁!";
GotoXY(90,23);cout<<" 祝您一路平安!";
for(int s=2;s<=37;s++)
{
GotoXY(85,s);cout<<"§";
}
SetConsoleTextAttribute(hout,0x0B);
}
void preservefile(common* p1, month* p2, year* p3, car* car1, car* car2, car* car3, ofstream& commonfile, ofstream& monthfile, ofstream& yearfile, ofstream& car1file, ofstream& car2file, ofstream& car3file) {
int i,j;
for (i = 0; i < common::getn(); i++) {
commonfile << p1[i].name << " " << p1[i].sex << " " << p1[i].phone << " " << p1[i].number << " " << p1[i].mima << " " << p1[i].money << " ";
for (j = 0; j < 3; j++) {
commonfile << p1[i].time2[j][0] << " " << p1[i].time2[j][1] << " " << p1[i].time2[j][2] << " " << p1[i].time2[j][3] << " ";
commonfile << p1[i].time2[j][4] << " " << p1[i].time2[j][5] << " ";
commonfile << p1[i].train[j][0] << " " << p1[i].train[j][1];
if (j != 2) { commonfile << " "; }
}
if (i + 1 == common::getn())break;
commonfile << endl;
}
for (i = 0; i < month::getn1(); i++) {
monthfile << p2[i].name << " " << p2[i].sex << " " << p2[i].phone << " " << p2[i].number << " " << p2[i].mima << " " << p2[i].money << " ";
monthfile << p2[i].flag << " " << p2[i].time22[0][0] << " " << p2[i].time22[0][1] << " ";
monthfile << p2[i].time22[0][2] << " " << p2[i].time22[0][3] << " " << p2[i].time22[0][4] << " " << p2[i].time22[0][5] << " ";
for (j = 0; j < 3; j++) {
monthfile << p2[i].time2[j][0] << " " << p2[i].time2[j][1] << " " << p2[i].time2[j][2] << " " << p2[i].time2[j][3] << " ";
monthfile << p2[i].time2[j][4] << " " << p2[i].time2[j][5] << " ";
monthfile << p2[i].train[j][0] << " " << p2[i].train[j][1];
if (j != 2) { monthfile << " "; }
}
if (i + 1 == month::getn1())break;
monthfile << endl;
}
for (i = 0; i < year::getn2(); i++) {
yearfile << p3[i].name << " " << p3[i].sex << " " << p3[i].phone << " " << p2[i].number << " " << p3[i].mima << " " << p3[i].money << " ";
yearfile << p3[i].flag << " " << p3[i].time22[0][0] << " " << p3[i].time22[0][1] << " ";
yearfile << p3[i].time22[0][2] << " " << p3[i].time22[0][3] << " " << p3[i].time22[0][4] << " " << p3[i].time22[0][5] << " ";
for (j = 0; j < 3; j++) {
yearfile << p3[i].time2[j][0] << " " << p3[i].time2[j][1] << " " << p3[i].time2[j][2] << " " << p3[i].time2[j][3] << " ";
yearfile << p3[i].time2[j][4] << " " << p3[i].time2[j][5] << " ";
yearfile << p3[i].train[j][0] << " " << p3[i].train[j][1];
if (j != 2) { yearfile << " "; }
}
if (i + 1 == year::getn2())break;
yearfile << endl;
}
for (i = 0; i < car::getcar111(); i++) {
car1file << car1[i].carnumber << " " << car1[i].flag << " " << car1[i].letter<<" "<<car1[i].people;
if (i + 1 == car::getcar111())break;
car1file << endl;
}
for (i = 0; i < car::getcar222(); i++) {
car2file << car2[i].carnumber << " " << car2[i].flag << " " << car2[i].letter<<" "<<car2[i].people;
if (i + 1 == car::getcar222())break;
car2file << endl;
}
for (i = 0; i < car::getcar333(); i++) {
car3file << car3[i].carnumber << " " << car3[i].flag << " " << car3[i].letter<<" "<<car3[i].people;
if (i + 1 == car::getcar333())break;
car3file << endl;
}
}
void zhuanhuan1(common* p1, month* p2, year* p3, int& x, int& y, int a)
{
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
int i, j;
if (x == 1)//原先普通
{
if (a == 1) {
p2[month::getn1() - 1].name = p1[y].name;
p2[month::getn1() - 1].sex = p1[y].sex;
p2[month::getn1() - 1].number = p1[y].number;
p2[month::getn1() - 1].phone = p1[y].phone;
p2[month::getn1() - 1].money = p1[y].money - 10;
p2[month::getn1() - 1].mima = p1[y].mima;
p2[month::getn1() - 1].time22[0][0] = timeinfo->tm_year + 1900;
p2[month::getn1() - 1].time22[0][1] = timeinfo->tm_mon + 1 + 1;
p2[month::getn1() - 1].time22[0][2] = timeinfo->tm_mday;
p2[month::getn1() - 1].time22[0][3] = timeinfo->tm_hour;
p2[month::getn1() - 1].time22[0][4] = timeinfo->tm_min;
p2[month::getn1() - 1].time22[0][5] = timeinfo->tm_sec;
}
if (a == 2) {
p3[year::getn2() - 1].name = p1[y].name;
p3[year::getn2() - 1].sex = p1[y].sex;
p3[year::getn2() - 1].number = p1[y].number;
p3[year::getn2() - 1].phone = p1[y].phone;
p3[year::getn2() - 1].money = p1[y].money - 100;
p3[year::getn2() - 1].mima = p1[y].mima;
p3[year::getn2() - 1].time22[0][0] = timeinfo->tm_year + 1900;
p3[year::getn2() - 1].time22[0][1] = timeinfo->tm_mon + 1 + 1;
p3[year::getn2() - 1].time22[0][2] = timeinfo->tm_mday;
p3[year::getn2() - 1].time22[0][3] = timeinfo->tm_hour;
p3[year::getn2() - 1].time22[0][4] = timeinfo->tm_min;
p3[year::getn2() - 1].time22[0][5] = timeinfo->tm_sec;
}
}
if (x == 2)//原先月卡
{
if (a == 1) {
p1[common::getn() - 1].name = p2[y].name;
p1[common::getn() - 1].sex = p2[y].sex;
p1[common::getn() - 1].number = p2[y].number;
p1[common::getn() - 1].phone = p2[y].phone;
p1[common::getn() - 1].money = p2[y].money;
p1[common::getn() - 1].mima = p2[y].mima;
}
if (a == 2) {
p3[year::getn2() - 1].name = p2[y].name;
p3[year::getn2() - 1].sex = p2[y].sex;
p3[year::getn2() - 1].number = p2[y].number;
p3[year::getn2() - 1].phone = p2[y].phone;
p3[year::getn2() - 1].money = p2[y].money;
p3[year::getn2() - 1].mima = p2[y].mima;
p3[year::getn2() - 1].time22[0][0] = p2[y].time22[0][0];
p3[year::getn2() - 1].time22[0][1] = p2[y].time22[0][1];
p3[year::getn2() - 1].time22[0][2] = p2[y].time22[0][2];
p3[year::getn2() - 1].time22[0][3] = p2[y].time22[0][3];
p3[year::getn2() - 1].time22[0][4] = p2[y].time22[0][4];
p3[year::getn2() - 1].time22[0][5] = p2[y].time22[0][5];
}
}
if (x == 3)//原先年卡
{
if (a == 1) {
p1[common::getn() - 1].name = p3[y].name;
p1[common::getn() - 1].sex = p3[y].sex;
p1[common::getn() - 1].number = p3[y].number;
p1[common::getn() - 1].phone = p3[y].phone;
p1[common::getn() - 1].money = p3[y].money;
p1[common::getn() - 1].mima = p3[y].mima;
}
if (a == 2) {
p2[month::getn1() - 1].name = p3[y].name;
p2[month::getn1() - 1].sex = p3[y].sex;
p2[month::getn1() - 1].number = p3[y].number;
p2[month::getn1() - 1].phone = p3[y].phone;
p2[month::getn1() - 1].money = p3[y].money;
p2[month::getn1() - 1].mima = p3[y].mima;
p2[month::getn1() - 1].time22[0][0] = p3[y].time22[0][0];
p2[month::getn1() - 1].time22[0][1] = p3[y].time22[0][1];
p2[month::getn1() - 1].time22[0][2] = p3[y].time22[0][2];
p2[month::getn1() - 1].time22[0][3] = p3[y].time22[0][3];
p2[month::getn1() - 1].time22[0][4] = p3[y].time22[0][4];
p2[month::getn1() - 1].time22[0][5] = p3[y].time22[0][5];
}
}
}
//转换不同用户类型数据
void zhuanhuan(common* p1, month* p2, year* p3, int& x, int& y)
{
for (;;)
{
system("cls");
string x111;
int x1;
cout << "请输入您的卡号:" << endl;
cin >> x1;
cout << "请输入您的密码:" << endl;
cin >> x111;
int i = common::n;
int j, flag1 = 0, flag2=0;
for (j = 0; j < i; j++)
{
if (p1[j].number == x1)
{
if (x111 == p1[j].mima) {
x = 1;
y = j; p1[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}
if (flag1 == 1) { break; }
i = month::n1;
for (j = 0; j < i; j++)
{
if (p2[j].number == x1)
{
if (x111 == p2[j].mima) {
x = 2;
y = j; p2[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = year::n2;
for (j = 0; j < i; j++)
{
if (p3[j].number == x1)
{
if (x111 == p3[j].mima) {
x = 3;
y = j; p3[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
if (flag1 == 0&& flag2 == 0) {
cout << "输入的卡号不存在!" << endl;
}
cout << "继续查询请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
//找卡
void addticket(car* car1, car* car2, car* car3, common* p1, int y)
{//预测乘客量 7-9 9-11 11-14 14-18 18-20 20-23 专门用来记录历史数据 200以上高峰 200-115即将到达高峰 115以下人数较少
for (;;) {
cout << endl;
road1 road;//用来展示线路
string x1, x2, x3 = "--";
if (p1[y].money < 0) { cout << "余额不足!请前往充值!"; Sleep(2000); break; }
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
int i11 = timeinfo->tm_hour,i12;
if (i11 >= 7 && i11 <= 8) {
i12 = person::getyucepassenger0();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 9 && i11 <= 10) {
i12 = person::getyucepassenger1();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 11 && i11 <= 13) {
i12 = person::getyucepassenger2();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if(i11 >= 14 && i11 <= 17) {
i12 = person::getyucepassenger3();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 18 && i11 <= 19) {
i12 = person::getyucepassenger4();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 20 && i11 <= 22) {
i12 = person::getyucepassenger5();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
system("pause");
system("cls");
int i2 = 5;//中南大学编号
int i, j;
int i3;
string i1 = "--";
road.showroad();
cout<<endl;
cout << "您的始发地为:" << p1[y].begin << endl;
cout << "请选择您的目的地:" ;
cin>>p1[y].end;
i=transform(p1[y].end);
i3 = i;
p1[y].train[p1[y].num][1] = p1[y].begin + i1 + p1[y].end;
if (i > i2) { i = i - i2; }
else { i = i2 - i; }
if (i < 2) { p1[y].price = 2; }
else { p1[y].price = 3; }
p1[y].time2[p1[y].num][0] = timeinfo->tm_year + 1900;
p1[y].time2[p1[y].num][1] = timeinfo->tm_mon + 1;
p1[y].time2[p1[y].num][2] = timeinfo->tm_mday;
p1[y].time2[p1[y].num][3] = timeinfo->tm_hour;
p1[y].time2[p1[y].num][4] = timeinfo->tm_min;
p1[y].time2[p1[y].num][5] = timeinfo->tm_sec;
cout << "可选择的列车有:" << endl;
if (i3 >= road1::stationxian[0] && i3 <= road1::stationxian[1]) {
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cin >> i;
p1[y].train[p1[y].num][0] = car1[i].carnumber;
p1[y].money -= p1[y].price;
car1[i].people += 1;
cout << "购票成功!";
p1[y].showticket(); p1[y].setnum(); break;
}
else if (i3 >= road1::stationxian[2] && i3 <= road1::stationxian[3])
{
cout << "您选择的目的地需要换乘,请在1号线和2号线分别选择两趟车次" << endl;
cout << "1号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x1 = car1[i].carnumber;
car1[i].people += 1;
cout << "2号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar222(); i3++)
{
if (car2[i3].flag == 1) {
cout << "车次编号:" << car2[i3].carnumber << " 当前运载人数:" << car2[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x2 = car2[i].carnumber;
car2[i].people += 1;
p1[y].train[p1[y].num][0] = x1 + x3 + x2;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket(); p1[y].setnum(); break;
}
else
{
cout << "您选择的目的地需要换乘,请在1号线和3号线分别选择两趟车次" << endl;
cout << "3号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar333(); i3++)
{
if (car3[i3].flag == 1) {
cout << "车次编号:" << car3[i3].carnumber << " 当前运载人数:" << car3[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x1 = car3[i].carnumber;
car3[i].people += 1;
cout << "1号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x2 = car1[i].carnumber;
car1[i].people += 1;
p1[y].train[p1[y].num][0] = x1 + x3 + x2;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket(); p1[y].setnum();break;
}
}
}
void addticket(car* car1, car* car2, car* car3, month* p1, int y)
{
for (;;) {
cout << endl;
//double transform(string c);
road1 road;//用来展示线路
string x1, x2, x3 = "--";
if (p1[y].money < 0) { cout << "余额不足!请前往充值!"; Sleep(2000); break; }
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
int i11 = timeinfo->tm_hour, i12;
if (i11 >= 7 && i11 <= 8) {
i12 = person::getyucepassenger0();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 9 && i11 <= 10) {
i12 = person::getyucepassenger1();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 11 && i11 <= 13) {
i12 = person::getyucepassenger2();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 14 && i11 <= 17) {
i12 = person::getyucepassenger3();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 18 && i11 <= 19) {
i12 = person::getyucepassenger4();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 20 && i11 <= 22) {
i12 = person::getyucepassenger5();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
system("pause");
system("cls");
int i2 = 5;//中南大学编号
int i, j;
int i3;
string i1 = "--";
road.showroad();
cout<<endl;
cout << "您的始发地为:" << p1[y].begin << endl;
cout << "请选择您的目的地:" ;
cin>>p1[y].end;
i=transform(p1[y].end);
i3 = i;
p1[y].train[p1[y].num][1] = p1[y].begin + i1 + p1[y].end;
if (i > i2) { i = i - i2; }
else { i = i2 - i; }
if (i < 2) { p1[y].price = 1.6; }
else { p1[y].price = 2.4; }
p1[y].time2[p1[y].num][0] = timeinfo->tm_year + 1900;
p1[y].time2[p1[y].num][1] = timeinfo->tm_mon + 1;
p1[y].time2[p1[y].num][2] = timeinfo->tm_mday;
p1[y].time2[p1[y].num][3] = timeinfo->tm_hour;
p1[y].time2[p1[y].num][4] = timeinfo->tm_min;
p1[y].time2[p1[y].num][5] = timeinfo->tm_sec;
cout << "可选择的列车有:" << endl;
if (i3 >= road1::stationxian[0] && i3 <= road1::stationxian[1]) {
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cin >> i;
p1[y].train[p1[y].num][0] = car1[i].carnumber;
car1[i].people += 1;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket();p1[y].setnum(); break;
}
else if (i3 >= road1::stationxian[2] && i3 <= road1::stationxian[3])
{
cout << "您选择的目的地需要换乘,请在1号线和2号线分别选择两趟车次" << endl;
cout << "1号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x1 = car1[i].carnumber;
car1[i].people += 1;
cout << "2号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar222(); i3++)
{
if (car2[i3].flag == 1) {
cout << "车次编号:" << car2[i3].carnumber << " 当前运载人数:" << car2[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x2 = car2[i].carnumber;
car2[i].people += 1;
p1[y].train[p1[y].num][0] = x1 + x3 + x2;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket();p1[y].setnum(); break;
}
else
{
cout << "您选择的目的地需要换乘,请在1号线和3号线分别选择两趟车次" << endl;
cout << "3号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar333(); i3++)
{
if (car3[i3].flag == 1) {
cout << "车次编号:" << car3[i3].carnumber << " 当前运载人数:" << car3[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x1 = car3[i].carnumber;
car3[i].people += 1;
cout << "1号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x2 = car1[i].carnumber;
car1[i].people += 1;
p1[y].train[p1[y].num][0] = x1 + x3 + x2;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket();p1[y].setnum(); break;
}
}
}
void addticket(car* car1, car* car2, car* car3, year* p1, int y) {
for (;;) {
cout << endl;
// double transform(string c);
road1 road;
string x1, x2, x3 = "--";
if (p1[y].money < 0) { cout << "余额不足!请前往充值!"; Sleep(2000); break; }
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
int i11 = timeinfo->tm_hour, i12;
if (i11 >= 7 && i11 <= 8) {
i12 = person::getyucepassenger0();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 9 && i11 <= 10) {
i12 = person::getyucepassenger1();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 11 && i11 <= 13) {
i12 = person::getyucepassenger2();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 14 && i11 <= 17) {
i12 = person::getyucepassenger3();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 18 && i11 <= 19) {
i12 = person::getyucepassenger4();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
else
if (i11 >= 20 && i11 <= 22) {
i12 = person::getyucepassenger5();
if (i12 < 115) { cout << "这段时间地铁站人数较少\n\n"; }
else
if (i12 < 200) { cout << "这段时间地铁站人数较多,可能会达到高峰\n\n"; }
else
{
cout << "这段时间地铁站人数达到高峰\n\n";
}
}
system("pause");
system("cls");
int i2 = 5;//中南大学编号
int i, j;
int i3;
string i1 = "--";
road.showroad();
cout<<endl;
cout << "您的始发地为:" << p1[y].begin << endl;
cout << "请选择您的目的地:" ;
cin>>p1[y].end;
i=transform(p1[y].end);
i3 = i;
p1[y].train[p1[y].num][1] = p1[y].begin + i1 + p1[y].end;
if (i > i2) { i = i - i2; }
else { i = i2 - i; }
if (i < 2) { p1[y].price = 2*0.7; }
else { p1[y].price = 3*0.7; }
p1[y].time2[p1[y].num][0] = timeinfo->tm_year + 1900;
p1[y].time2[p1[y].num][1] = timeinfo->tm_mon + 1;
p1[y].time2[p1[y].num][2] = timeinfo->tm_mday;
p1[y].time2[p1[y].num][3] = timeinfo->tm_hour;
p1[y].time2[p1[y].num][4] = timeinfo->tm_min;
p1[y].time2[p1[y].num][5] = timeinfo->tm_sec;
cout << "可选择的列车有:" << endl;
if (i3 >= road1::stationxian[0] && i3 <= road1::stationxian[1]) {
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cin >> i;
p1[y].train[p1[y].num][0] = car1[i].carnumber;
car1[i].people += 1;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket(); p1[y].setnum(); break;
}
else if (i3 >= road1::stationxian[2] && i3 <= road1::stationxian[3])
{
cout << "您选择的目的地需要换乘,请在1号线和2号线分别选择两趟车次" << endl;
cout << "1号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x1 = car1[i].carnumber;
car1[i].people += 1;
cout << "2号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar222(); i3++)
{
if (car2[i3].flag == 1) {
cout << "车次编号:" << car2[i3].carnumber << " 当前运载人数:" << car2[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x2 = car2[i].carnumber;
car2[i].people += 1;
p1[y].train[p1[y].num][0] = x1 + x3 + x2;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket();p1[y].setnum(); break;
}
else
{
cout << "您选择的目的地需要换乘,请在1号线和3号线分别选择两趟车次" << endl;
cout << "3号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar333(); i3++)
{
if (car3[i3].flag == 1) {
cout << "车次编号:" << car3[i3].carnumber << " 当前运载人数:" << car3[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x1 = car3[i].carnumber;
car3[i].people += 1;
cout << "1号线正在运行的车次:" << endl;
for (i3 = 0; i3 < car::getcar111(); i3++)
{
if (car1[i3].flag == 1) {
cout << "车次编号:" << car1[i3].carnumber << " 当前运载人数:" << car1[i3].people << "(按" << i3 << "可选)" << endl;
}
}
cout << "请选择乘坐的车次:" << endl;
cin >> i;
x2 = car1[i].carnumber;
car1[i].people += 1;
p1[y].train[p1[y].num][0] = x1 + x3 + x2;
p1[y].money -= p1[y].price;
cout << "购票成功!";
p1[y].showticket(); p1[y].setnum();break;
}
}
}
void ticketjilu(common* p1, int y)
{
int i;
cout << "车次\t\t\t" << "乘车区间\t\t\t" << " 购票时间\t\n";
for (i = 0; i < 3; i++)
{
cout << p1[y].train[i][0] << "\t\t" << p1[y].train[i][1] << "\t\t" << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << endl;
}
system("pause");
}
void ticketjilu(month* p1, int y)
{
int i;
cout << "车次\t\t\t" << "乘车区间\t\t\t" << " 购票时间\t\n";
for (i = 0; i < 3; i++)
{
cout << p1[y].train[i][0] << "\t\t" << p1[y].train[i][1] << "\t\t" << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << endl;
}
system("pause");
}
void ticketjilu(year* p1, int y)
{
int i;
cout << "车次\t\t\t" << "乘车区间\t\t\t" << " 购票时间\t\n";
for (i = 0; i < 3; i++)
{
cout << p1[y].train[i][0] << "\t\t" << p1[y].train[i][1] << "\t\t" << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << endl;
}
system("pause");
}
void deletepiao(common* p1, car* car1, car* car2, car* car3, int y) {
for (;;) {
int i, j, flag1 = 0;
string x1, x2;//记录车次
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
for (i = 0; i < 3; i++)
{
if (p1[y].time2[i][0] == timeinfo->tm_year + 1900 && p1[y].time2[i][1] == timeinfo->tm_mon + 1 && p1[y].time2[i][2] == timeinfo->tm_mday)
{
if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] <= timeinfo->tm_min && p1[y].time2[i][4] + 10 > timeinfo->tm_min) {
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] + 10 == timeinfo->tm_min && p1[y].time2[i][5] < timeinfo->tm_sec) {
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] <= timeinfo->tm_hour && p1[y].time2[i][4] + 10 > timeinfo->tm_min + 60)
{
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] + 10 == timeinfo->tm_min + 60 && p1[y].time2[i][5] < timeinfo->tm_sec)
{
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
}
}
if (flag1 == 0) { cout << "您无近期购票信息或您已错过发车时间,不可退票!"; system("pause"); break; }
else {
cout << "请按提示输入您想要退的票:" << endl;
cin >> i;
if (i <= flag1) {
cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t发车时间\n";
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5] << endl;
cout << "您确定要退这张票吗?按1确定退票,否则按任意键:";
cin >> j;
if (j == 1) {
int y1;
y1 = p1[y].train[i][0].length();
if (y1 == 4) {
x1 = p1[y].train[i][0].substr(0, 4);
for (j = 0; j < car::getcar111(); j++) {
if (car1[j].carnumber == x1) {
car1[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar222(); j++) {
if (car2[j].carnumber == x1) {
car2[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar333(); j++) {
if (car3[j].carnumber == x1) {
car3[j].people -= 1;
break;
}
}
}
else
{
x1 = p1[y].train[i][0].substr(0, 4);
x2 = p1[y].train[i][0].substr(6, 10);
for (j = 0; j < car::getcar111(); j++) {
if (car1[j].carnumber == x1 || car1[j].carnumber == x2) {
car1[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar222(); j++) {
if (car2[j].carnumber == x1 || car2[j].carnumber == x2) {
car2[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar333(); j++) {
if (car3[j].carnumber == x1 || car3[j].carnumber == x2) {
car3[j].people -= 1;
break;
}
}
}
p1[y].money += p1[y].price;
p1[y].train[i][0] = "0"; p1[y].train[i][1] = "0"; p1[y].time2[i][0] = 0; p1[y].time2[i][1] = 0; p1[y].time2[i][2] = 0;
p1[y].time2[i][3] = 0; p1[y].time2[i][4] = 0; p1[y].time2[i][5] = 0;
cout << "退票成功!"; system("pause"); break;
}
else { cout << "退票失败!"; system("pause"); break; }
}
}
}
}
void deletepiao(month* p1, car* car1, car* car2, car* car3, int y) {
for (;;) {
int i, j, flag1 = 0;
string x1, x2;//记录车次
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
for (i = 0; i < 3; i++)
{
if (p1[y].time2[i][0] == timeinfo->tm_year + 1900 && p1[y].time2[i][1] == timeinfo->tm_mon + 1 && p1[y].time2[i][2] == timeinfo->tm_mday)
{
if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] <= timeinfo->tm_min && p1[y].time2[i][4] + 10 > timeinfo->tm_min) {
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] + 10 == timeinfo->tm_min && p1[y].time2[i][5] < timeinfo->tm_sec) {
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] <= timeinfo->tm_hour && p1[y].time2[i][4] + 10 > timeinfo->tm_min + 60)
{
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] + 10 == timeinfo->tm_min + 60 && p1[y].time2[i][5] < timeinfo->tm_sec)
{
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
}
}
if (flag1 == 0) { cout << "您无近期购票信息或您已错过发车时间,不可退票!"; system("pause"); break; }
else {
cout << "请按提示输入您想要退的票:" << endl;
cin >> i;
if (i <= flag1) {
cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t发车时间\n";
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5] << endl;
cout << "您确定要退这张票吗?按1确定退票,否则按任意键:";
cin >> j;
if (j == 1) {
int y1;
y1 = p1[y].train[i][0].length();
if (y1 == 4) {
x1 = p1[y].train[i][0].substr(0, 4);
for (j = 0; j < car::getcar111(); j++) {
if (car1[j].carnumber == x1) {
car1[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar222(); j++) {
if (car2[j].carnumber == x1) {
car2[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar333(); j++) {
if (car3[j].carnumber == x1) {
car3[j].people -= 1;
break;
}
}
}
else
{
x1 = p1[y].train[i][0].substr(0, 4);
x2 = p1[y].train[i][0].substr(6, 10);
for (j = 0; j < car::getcar111(); j++) {
if (car1[j].carnumber == x1 || car1[j].carnumber == x2) {
car1[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar222(); j++) {
if (car2[j].carnumber == x1 || car2[j].carnumber == x2) {
car2[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar333(); j++) {
if (car3[j].carnumber == x1 || car3[j].carnumber == x2) {
car3[j].people -= 1;
break;
}
}
}
p1[y].money += p1[y].price;
p1[y].train[i][0] = "0"; p1[y].train[i][1] = "0"; p1[y].time2[i][0] = 0; p1[y].time2[i][1] = 0; p1[y].time2[i][2] = 0;
p1[y].time2[i][3] = 0; p1[y].time2[i][4] = 0; p1[y].time2[i][5] = 0;
cout << "退票成功!"; system("pause"); break;
}
else { cout << "退票失败!"; system("pause"); break; }
}
}
}
}
void deletepiao(year* p1, car* car1, car* car2, car* car3, int y) {
for (;;) {
int i, j, flag1 = 0;
string x1, x2;//记录车次
time_t rawtime;
time(&rawtime);
struct tm* timeinfo;
timeinfo = localtime(&rawtime);
for (i = 0; i < 3; i++)
{
if (p1[y].time2[i][0] == timeinfo->tm_year + 1900 && p1[y].time2[i][1] == timeinfo->tm_mon + 1 && p1[y].time2[i][2] == timeinfo->tm_mday)
{
if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] <= timeinfo->tm_min && p1[y].time2[i][4] + 10 > timeinfo->tm_min) {
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] + 10 == timeinfo->tm_min && p1[y].time2[i][5] < timeinfo->tm_sec) {
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] <= timeinfo->tm_hour && p1[y].time2[i][4] + 10 > timeinfo->tm_min + 60)
{
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
else if (p1[y].time2[i][3] == timeinfo->tm_hour && p1[y].time2[i][4] + 10 == timeinfo->tm_min + 60 && p1[y].time2[i][5] < timeinfo->tm_sec)
{
flag1 += 1; if (flag1 == 1) { cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n"; }
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5];
cout << " (输入" << flag1 - 1 << "可退此票)" << endl;
}
}
}
if (flag1 == 0) { cout << "您无近期购票信息或您已错过发车时间,不可退票!"; system("pause"); break; }
else {
cout << "请按提示输入您想要退的票:" << endl;
cin >> i;
if (i <= flag1) {
cout << "车次编号\t\t\t乘车区间\t\t\t购票时间\t\t\t\t发车时间\n";
cout << p1[y].train[i][0] << "\t\t\t" << p1[y].train[i][1] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] << ":" << p1[y].time2[i][5] << "\t\t";
cout << p1[y].time2[i][0] << "年" << p1[y].time2[i][1] << "月" << p1[y].time2[i][2] << "日" << p1[y].time2[i][3] << ":" << p1[y].time2[i][4] + 10 << ":" << p1[y].time2[i][5] << endl;
cout << "您确定要退这张票吗?按1确定退票,否则按任意键:";
cin >> j;
if (j == 1) {
int y1;
y1 = p1[y].train[i][0].length();
if (y1 == 4) {
x1 = p1[y].train[i][0].substr(0, 4);
for (j = 0; j < car::getcar111(); j++) {
if (car1[j].carnumber == x1) {
car1[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar222(); j++) {
if (car2[j].carnumber == x1) {
car2[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar333(); j++) {
if (car3[j].carnumber == x1) {
car3[j].people -= 1;
break;
}
}
}
else
{
x1 = p1[y].train[i][0].substr(0, 4);
x2 = p1[y].train[i][0].substr(6, 10);
for (j = 0; j < car::getcar111(); j++) {
if (car1[j].carnumber == x1 || car1[j].carnumber == x2) {
car1[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar222(); j++) {
if (car2[j].carnumber == x1 || car2[j].carnumber == x2) {
car2[j].people -= 1;
break;
}
}
for (j = 0; j < car::getcar333(); j++) {
if (car3[j].carnumber == x1 || car3[j].carnumber == x2) {
car3[j].people -= 1;
break;
}
}
}
p1[y].money += p1[y].price;
p1[y].train[i][0] = "0"; p1[y].train[i][1] = "0"; p1[y].time2[i][0] = 0; p1[y].time2[i][1] = 0; p1[y].time2[i][2] = 0;
p1[y].time2[i][3] = 0; p1[y].time2[i][4] = 0; p1[y].time2[i][5] = 0;
cout << "退票成功!"; system("pause"); break;
}
else { cout << "退票失败!"; system("pause"); break; }
}
}
}
}
void searchcard(common* p1, month* p2, year* p3, int& x, int& y)
{
for (;;)
{
system("cls");
int x1;
string x111;
cout << "请输入您的卡号:" << endl;
cin >> x1;
cout << "请输入您的密码:" << endl;
cin >> x111;
int i = common::n;
int j, flag1 = 0, flag2 = 0;
for (j = 0; j < i; j++)
{
if (p1[j].number == x1)
{
if (x111 == p1[j].mima) {
x = 1;
y = j; p1[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}
if (flag1 == 1) { break; }
i = month::n1;
for (j = 0; j < i; j++)
{
if (p2[j].number == x1)
{
if (x111 == p2[j].mima) {
x = 2;
y = j; p2[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = year::n2;
for (j = 0; j < i; j++)
{
if (p3[j].number == x1)
{
if (x111 == p3[j].mima) {
x = 3;
y = j; p3[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
if (flag1 == 0&&flag2 ==0) {
cout << "输入的卡号不存在!" << endl;
}
cout << "继续查找请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
void tuika(common* p1, month* p2, year* p3, int& x, int& y)
{
for (;;)
{
system("cls");
int x1;
string x111;
cout << "请输入想要退卡的卡号:" << endl;
cin >> x1;
cout << "请输入您的密码:" << endl;
cin >> x111;
int i = common::n;
int j, flag1 = 0, flag2 = 0;
for (j = 0; j < i; j++)
{
if (p1[j].number == x1)
{
if (x111 == p1[j].mima) {
x = 1;
y = j; p1[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}
if (flag1 == 1) { break; }
i = month::n1;
for (j = 0; j < i; j++)
{
if (p2[j].number == x1)
{
if (x111 == p2[j].mima) {
x = 2;
y = j; p2[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = year::n2;
for (j = 0; j < i; j++)
{
if (p3[j].number == x1)
{
if (x111 == p3[j].mima) {
x = 3;
y = j; p3[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
if (flag1 == 0&&flag2==0) {
cout << "输入的卡号不存在!" << endl;
}
cout << "继续退卡请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
void deletecar(car* car1, car* car2, car* car3, int& x, int& y)
{
for (;;)
{
system("cls");
string x1;
cout << "请输入想要删除的车次:" << endl;
cin >> x1;
int i = car::car111;
int j, flag1 = 0;
for (j = 0; j < i; j++)
{
if (car1[j].carnumber == x1)
{
x = 1; y = j;
cout << "此车次在1号线" << endl;
car1[j].showcar();
flag1 = 1; break;
}
}
if (flag1 == 1) { break; }
i = car::car222;
for (j = 0; j < i; j++)
{
if (car2[j].carnumber == x1)
{
x = 2; y = j;
cout << "此车次在2号线" << endl;
car2[j].showcar();
flag1 = 1; break;
}
}if (flag1 == 1) { break; }
i = car::car333;
for (j = 0; j < i; j++)
{
if (car3[j].carnumber == x1)
{
x = 3; y = j;
cout << "此车次在3号线" << endl;
car3[j].showcar();
flag1 = 1; break;
}
}if (flag1 == 1) { break; }
if (flag1 == 0) {
cout << "输入的车次编号不存在!" << endl;
cout << "继续删除请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
}
//x保存几号线路 y保存这条线路的第几个车次
void searchcar(car* car1, car* car2, car* car3)
{
for (;;)
{
system("cls");
string x;
cout << "请输入想要查询的车次:" << endl;
cin >> x;
int i = car::car111;
int j, flag1 = 0;
for (j = 0; j < i; j++)
{
if (car1[j].carnumber == x)
{
cout << "此车次在1号线" << endl;
car1[j].showcar();
flag1 = 1; break;
}
}
if (flag1 == 1) { break; }
i = car::car222;
for (j = 0; j < i; j++)
{
if (car2[j].carnumber == x)
{
cout << "此车次在2号线" << endl;
car2[j].showcar();
flag1 = 1; break;
}
}if (flag1 == 1) { break; }
i = car::car333;
for (j = 0; j < i; j++)
{
if (car3[j].carnumber == x)
{
cout << "此车次在3号线" << endl;
car3[j].showcar();
flag1 = 1; break;
}
}if (flag1 == 1) { break; }
if (flag1 == 0) {
cout << "输入的车次编号不存在!" << endl;
cout << "继续查询请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
}
void searchcar1(car* car1, car* car2, car* car3)
{
for (;;)
{
system("cls");
string x;
cout << "请输入想要更改运行状态的车次:" << endl;
cin >> x;
int i = car::car111;
int j, flag1 = 0;
for (j = 0; j < i; j++)
{
if (car1[j].carnumber == x)
{
cout << "此车次在1号线" << endl;
car1[j].showcar();
car1[j].genggai();
flag1 = 1; break;
}
}
if (flag1 == 1) { break; }
i = car::car222;
for (j = 0; j < i; j++)
{
if (car2[j].carnumber == x)
{
cout << "此车次在2号线" << endl;
car2[j].showcar();
car1[j].genggai();
flag1 = 1; break;
}
}if (flag1 == 1) { break; }
i = car::car333;
for (j = 0; j < i; j++)
{
if (car3[j].carnumber == x)
{
cout << "此车次在3号线" << endl;
car3[j].showcar();
car1[j].genggai();
flag1 = 1; break;
}
}if (flag1 == 1) { break; }
if (flag1 == 0) {
cout << "输入的车次编号不存在!" << endl;
cout << "继续更改地铁车次运行状态请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
}
void revealcar(car* car1, car* car2, car* car3)
{
system("cls");
char i1;
int j;
int i;
cout << "查看正在运行的车次请按a,查看不正在运行的车次请按b,查看所有车次的情况请按c,请输入:" << endl;
cin >> i1;
if (i1 == 'a')
{
i = car::car111;
cout << "1号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car1[j].flag == 1)
{
cout << car1[j].carnumber << "\t\t" << car1[j].people << "\t\t" << car1[j].maxpeople << "\t\t" << car1[j].box << " \t";
cout << "是" << endl;
}
}
i = car::car222;
cout << "2号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car2[j].flag == 1)
{
cout << car2[j].carnumber << "\t\t" << car2[j].people << "\t\t" << car2[j].maxpeople << "\t\t" << car2[j].box << " \t";
cout << "是" << endl;
}
}
i = car::car333;
cout << "3号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car3[j].flag == 1)
{
cout << car3[j].carnumber << "\t\t" << car3[j].people << "\t\t" << car3[j].maxpeople << "\t\t" << car3[j].box << " \t";
cout << "是" << endl;
}
}
system("pause");
}
if (i1 == 'b')
{
i = car::car111;
cout << "1号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car1[j].flag == 0)
{
cout << car1[j].carnumber << "\t\t" << car1[j].people << "\t\t" << car1[j].maxpeople << "\t\t" << car1[j].box << " \t";
cout << "否" << endl;
}
}
i = car::car222;
cout << "2号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car2[j].flag == 0)
{
cout << car2[j].carnumber << "\t\t" << car2[j].people << "\t\t" << car2[j].maxpeople << "\t\t" << car2[j].box << " \t";
cout << "否" << endl;
}
}
i = car::car333;
cout << "3号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car3[j].flag == 0)
{
cout << car3[j].carnumber << "\t\t" << car3[j].people << "\t\t" << car3[j].maxpeople << "\t\t" << car3[j].box << " \t";
cout << "否" << endl;
}
}
system("pause");
}
if (i1 == 'c')
{
i = car::car111;
cout << "1号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
cout << car1[j].carnumber << "\t\t" << car1[j].people << "\t\t" << car1[j].maxpeople << "\t\t" << car1[j].box << " \t";
if (car1[j].flag == 1) { cout << "是" << endl; }
else { cout << "否" << endl; }
}
i = car::car222;
cout << "2号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
cout << car2[j].carnumber << "\t\t" << car2[j].people << "\t\t" << car2[j].maxpeople << "\t\t" << car2[j].box << " \t";
if (car2[j].flag == 1) { cout << "是" << endl; }
else { cout << "否" << endl; }
}
i = car::car333;
cout << "3号线上的车次" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
cout << car3[j].carnumber << "\t\t" << car3[j].people << "\t\t" << car3[j].maxpeople << "\t\t" << car3[j].box << " \t";
if (car3[j].flag == 1) { cout << "是" << endl; }
else { cout << "否" << endl; }
}
system("pause");
}
}
//显示每条线路车次
void revealroad1(car* car1, car* car2, car* car3, int i)
{
int j;
int i1 = 0;
if (i == 1)
{
cout << "1号线" << endl;
cout << "经过的站点有:";
for (i = road1::stationxian[0] - 1; i < road1::stationxian[1]; i++)
{
cout << road1::station[i];
if (i != road1::stationxian[1] - 1) { cout << "---"; }
else { cout << endl << endl; }
}
i = car::car111;
cout << "正在运行的车次有:" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car1[j].flag == 1)
{
cout << car1[j].carnumber << "\t\t" << car1[j].people << "\t\t" << car1[j].maxpeople << "\t\t" << car1[j].box << " \t";
cout << "是" << endl;
}
}
cout << "总运载人数为:";
for (j = 0; j < i; j++)
{
i1 = car1[j].people;
}
cout << i1 << endl;
system("pause");
}
if (i == 2)
{
cout << "2号线" << endl;
cout << "经过的站点有:";
for (i = road1::stationxian[2] - 1; i < road1::stationxian[3]; i++)
{
cout << road1::station[i];
if (i != road1::stationxian[3] - 1) { cout << "---"; }
else { cout << endl << endl; }
}
i = car::car222;
cout << "正在运行的车次有:" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car2[j].flag == 1)
{
cout << car2[j].carnumber << "\t\t" << car2[j].people << "\t\t" << car2[j].maxpeople << "\t\t" << car2[j].box << " \t";
cout << "是" << endl;
}
}
cout << endl;
cout << "总运载人数为:";
for (j = 0; j < i; j++)
{
i1 = car2[j].people;
}
cout << i1 << endl;
system("pause");
}
if (i == 3)
{
cout << "3号线" << endl;
cout << "经过的站点有:";
for (i = road1::stationxian[4] - 1; i < road1::stationxian[5]; i++)
{
cout << road1::station[i];
if (i != road1::stationxian[5] - 1) { cout << "---"; }
else { cout << endl << endl; }
}
i = car::car333;
cout << "正在运行的车次有:" << endl;
cout << "车次编号\t" << "当前运载人数\t" << "最大运载人数\t" << "车厢数\t" << "是否正在运行" << endl;
for (j = 0; j < i; j++)
{
if (car3[j].flag == 1)
{
cout << car1[j].carnumber << "\t\t" << car3[j].people << "\t\t" << car3[j].maxpeople << "\t\t" << car3[j].box << " \t";
cout << "是" << endl;
}
}
cout << "总运载人数为:";
for (j = 0; j < i; j++)
{
i1 = car3[j].people;
}
cout << i1 << endl;
system("pause");
}
}
void chaxun(common* p1, month* p2, year* p3)
{
for (;;)
{
system("cls");
string x111;
int x;
cout << "请输入想要查询的卡号:" << endl;
cin >> x;
cout << "请输入您的密码:" << endl;
cin >> x111;
int i = common::n;
int j, flag1 = 0;
int flag2 = 0;
for (j = 0; j < i; j++)
{
if (p1[j].number == x)
{
if (x111 == p1[j].mima) {
p1[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}
if (flag1 == 1) { break; }
i = month::n1;
for (j = 0; j < i; j++)
{
if (p2[j].number == x)
{
if (x111 == p2[j].mima) {
p2[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = year::n2;
for (j = 0; j < i; j++)
{
if (p3[j].number == x)
{
if (x111 == p3[j].mima) {
p3[j].zhanshi();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
if (flag1 == 0&&flag2 == 0) {
cout << "输入的卡号不存在!" << endl;
}
cout << "继续查询请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
//用户查询卡号
void xufei(common* p1, month* p2, year* p3, int& x, int& y) {
for (;;)
{
system("cls");
string x111;
int x1;
cout << "请输入您的卡号:" << endl;
cin >> x1;
cout << "请输入您的密码:" << endl;
cin >> x111;
int i = common::n;
int j, flag1 = 0, flag2;
for (j = 0; j < i; j++)
{
if (p1[j].number == x1)
{
if (x111 == p1[j].mima) {
x = 1;
y = j; p1[j].zhanshi();
p1[j].xufei();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}
if (flag1 == 1) { break; }
i = month::n1;
for (j = 0; j < i; j++)
{
if (p2[j].number == x1)
{
if (x111 == p2[j].mima) {
x = 2;
y = j; p2[j].zhanshi();
p2[j].xufei();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = year::n2;
for (j = 0; j < i; j++)
{
if (p3[j].number == x1)
{
if (x111 == p3[j].mima) {
x = 3;
y = j; p3[j].zhanshi();
p3[j].xufei();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
if (flag1 == 0 && flag2 == 0) {
cout << "输入的卡号不存在!" << endl;
}
cout << "继续查询请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
void chongzhi(common* p1, month* p2, year* p3)
{
for (;;)
{
system("cls");
int x;
string x111;
cout << "请输入想要充值的卡号:" << endl;
cin >> x;
cout << "请输入您的密码:" << endl;
cin >> x111;
int i = common::n;
int j, flag1 = 0, flag2 = 0;
for (j = 0; j < i; j++)
{
if (p1[j].number == x)
{
if (x111 == p1[j].mima) {
p1[j].xiugai();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = month::n1;
for (j = 0; j < i; j++)
{
if (p2[j].number == x)
{
if (x111 == p2[j].mima) {
p2[j].xiugai();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
i = year::n2;
for (j = 0; j < i; j++)
{
if (p3[j].number == x)
{
if (x111 == p3[j].mima) {
p3[j].xiugai();
flag1 = 1; break;
}
else
{
flag2 = 1;
cout << "密码错误!" << endl; system("pause"); break;
}
}
}if (flag1 == 1) { break; }
if (flag1 == 0&&flag2 ==0) {
cout << "输入的卡号不存在!" << endl;
}
cout << "继续充值请按任意数,否则请按2:" << endl;
cin >> flag1;
if (flag1 == 2) { break; }
}
}
void week(tm* s)
{
int i;
i = s->tm_wday;
if (i == 0)cout << "天";
if (i == 1)cout << "一";
if (i == 2)cout << "二";
if (i == 3)cout << "三";
if (i == 4)cout << "四";
if (i == 5)cout << "五";
if (i == 6)cout << "六";
}
void minute(tm* s)
{
int i = s->tm_min;
if (i < 10)cout << "0" << i;
else cout << i;
}
void second(tm* s)
{
int i = s->tm_sec;
if (i < 10)cout << "0" << i;
else cout << i;
}
总结
感谢观看,最后附上源代码文档