网站建设如何选择服务器,住房和城乡建设部政务服务门户app,莱芜征婚吧,如何给网站建设提意见该程序具有以下功能
(1) 一个地铁路线类 Router#xff0c;包含路线编号#xff0c;途中的各个站点。可以新增、删除、查询路线#xff0c;可以根据线路名称#xff0c;显示线路图片。 (2) 一个地图类 Map#xff0c;可以显示所有可以乘坐的地铁站名#xff0c;以及线路…该程序具有以下功能
(1) 一个地铁路线类 Router包含路线编号途中的各个站点。可以新增、删除、查询路线可以根据线路名称显示线路图片。 (2) 一个地图类 Map可以显示所有可以乘坐的地铁站名以及线路信息。 (3) 根据用户选择起点和终点和人次信息可以自动计算应付金额根据用户输入的金额计算找零信息 (4) 使用外部文件存储路线相关信息。
#include iostream
#include vector
using namespace std;class Router {private:string port[100];//经过站点int id;//路线编号int count0; //站点数目public:void setId(int i) {idi;}void addPort(string name) {port[count]name;count;}void getPort() {int i0;for(i0; icount; i) {cout第i1站;coutport[i];coutendl;}}int check(string u,string v) {int d0;for(int i0; icount; i) {if(port[i]u) {for(int j0; jcount; j) {if(port[j]v) {// u vreturn ((i-j)0)?(i-j):(j-i);}}}}return 0;}
};class Map {private:vectorRouter r;//路线图public:double charge2;//每站价格void setCharge(double ch) {chargech;}void init() {Router temp1;temp1.setId(1);temp1.addPort(west);temp1.addPort(mid1);temp1.addPort(south);r.push_back(temp1);Router temp2;temp2.setId(2);temp2.addPort(south);temp2.addPort(mid2);temp2.addPort(east);r.push_back(temp2);Router temp3;temp3.setId(3);temp3.addPort(east);temp3.addPort(mid3);temp3.addPort(north);r.push_back(temp3);Router temp4;temp4.setId(4);temp4.addPort(north);temp4.addPort(mid4);temp4.addPort(west);r.push_back(temp4);}int buy(string start, string end) {int countr.size();int d0;for(int i0; icount; i) {Router tempr[i];dtemp.check(start,end);if(d0) {cout您需要乘坐i1号线endl;return d;}}return 0;}void show() {int countr.size();cout本市地铁线路图如下endl;for(int i0; icount; i) {couti1号线endlendl;Router tempr[i];temp.getPort();coutendlendl;}}
};void menu() {int m;Map map;map.init();while(1) {coutendlendlendl;cout----------欢迎来到地铁售票系统-----------endl;cout----------1、路线查询-----------endl;cout----------2、购票-----------endl;cinm;if(m1) {map.show();} else if(m2) {cout请输入起点endl;string s;cins;cout请输入终点endl;string e;cine;cout请输入人数endl;int c;cinc;int dmap.buy(s,e);if(d0) {double rs(double)c*(double)d*map.charge;cout您需要支付的费用为;coutrsendl;cout请输入您支付的金额;double in0;cinin;if(inrs) {cout购票成功endl;cout找零in-rs元endl;} else {cout金额不足购票失败;}} else {cout抱歉请选择其他交通;}}}
}int main() {menu();return 0;
}