1、#include#include#include#include#include using namespace std;class Bus_inforint No; static int Bus_No;char start20;char end20;int Bus_order; int all_tickted;int tickted;int Hour_start,Minute_start,Hour_end,Minute_end;int Hour;int Minute;public:Bus_infor *next;Bus_infor();Bus_infor();int Get_no();int
2、 Get_all_tickted();int Get_tickted();int Get_bus_order(); char *Get_start();char *Get_end();void addr(); void Order_tickt(int n);void Unorder_tickt(int n);void GetTime_start();void GetTime_end();void ShowTime();void GetTime();void Show_infor(); void input()coutttt按提示输入:endl;coutBus_order;coutall_tic
3、kted;GetTime_start();GetTime_end();addr();char a;cout与否清空售票(y/n)?a;if(a=y) tickted=0; void input(ifstream & is) isBus_orderstartendall_ticktedticktedHour_startMinute_startHour_endMinute_end;is.get(); void output()cout客车基本信息如下:endl;cout车次:Bus_order 发车时间:Hour_start: Minute_start 起点站:start 终点站:end行车时间H
4、our_end: Minute_end额定载量all_tickted已订票人数tickted: Minute_endendlendl; void output(ofstream & os) ossetw(6)Bus_ordersetw(15)startsetw(6)endsetw(15)all_ticktedsetw(15)ticktedsetw(15)Hour_startsetw(15)Minute_startsetw(15)Hour_endsetw(15)Minute_endendl;int Bus_infor:Bus_No=1;void Bus_infor:GetTime_start()
5、int NewH=0,NewM=0;cout请输入发车时间:NewHNewM;Hour_start=NewH;Minute_start=NewM;void Bus_infor:GetTime_end()int NewH=0,NewM=0;cout请输入行车时间:NewHNewM;Hour_end=NewH;Minute_end=NewM;void Bus_infor:GetTime()if(Minute_end=Minute_start)Minute=(Minute_end-Minute_start); Hour=(Hour_end-Hour_start); else Minute=(Minu
6、te_end-Minute_start+60); Hour=(Hour_end-Hour_start-1); void Bus_infor:ShowTime()coutHour_start:Minute_start ; coutHour_end:Minute_end ;coutHour:Minuteendl;Bus_infor:Bus_infor()No=Bus_No+; tickted=0;Bus_infor:Bus_infor() Bus_No-; void Bus_infor:addr()cout请输入起点站与终点站:a;cinb;strcpy(start,a);strcpy(end,b
7、);char *Bus_infor:Get_start()return start;char *Bus_infor:Get_end()return end;int Bus_infor:Get_no() return No;int Bus_infor:Get_all_tickted()return all_tickted;int Bus_infor:Get_tickted()return tickted;int Bus_infor:Get_bus_order()return Bus_order;void Bus_infor:Order_tickt(int n)tickted=tickted+n;
8、void Bus_infor:Unorder_tickt(int n)tickted=tickted-n;class Bus_linkpublic:Bus_link()head=new Bus_infor;head-next=NULL;key=0;void input();void mend();void del();int find(Bus_infor *p,int num,char *pn); int find1(Bus_infor *p,int num,char *pn); void found();void show(); void Order(); void Unorder(); v
9、oid save(); void begin(); void clear(); char mainmenu(); int getkey() return key; void setkey(int k) key=k; private: Bus_infor *head; int key;void Bus_link:input()Bus_infor *p,*p2=NULL;p=head; int n;while(p-next)p=p-next;while(n)p2=new Bus_infor;p2-input();p-next=p2;p2-next=NULL;p=p-next; Bus_link:s
10、etkey(1);coutn;void Bus_link:Order()Bus_infor *p;cout拟定购票(y/n)?X;if(X=y)int num;coutnum;if( !find1(&p,num,) )couttt找不到你要定票旳车辆旳内容!endl;return;coutn;p=p-next;if(p-Get_tickted()+n)Get_all_tickted()p-Order_tickt(n);cout谢谢使用endl;else cout对不起,没有足够旳票数。endl; else if(X=n) cout谢谢使用endl;else cout输入字符不拟定endl;Bu
11、s_link:setkey(1);void Bus_link:Unorder()Bus_infor *p;cout拟定退票(y/n)?X;if(X=y)int num;coutnum;if( !find1(&p,num,) )couttt找不到你要定票旳车辆旳内容!endl;return;coutn;p=p-next;if(p-Get_tickted()-n)=0)p-Unorder_tickt(n);else cout对不起,数据出错!。endl; else if(X=n) cout谢谢使用endl;else cout输入字符不拟定endl;Bus_link:setkey(1);void B
12、us_link:found()Bus_infor *p;int num=-1,n=9;char name20=;docoutn;while(n2);if(n=1)coutnum;if(n=2)coutname;if(!find(&p,num,name)couttt找不到你要查找旳内容!next)(*p1)=p;if( (p-next)-Get_bus_order()=num|!strcmp( (p-next)-Get_end(),pn ) )(p-next)-output(); t=1;break;p=p-next;return t;int Bus_link:find1(Bus_infor *
13、p1,int num,char *pn)Bus_infor *p;p=head;int t=0;while(p-next)(*p1)=p;if( (p-next)-Get_bus_order()=num|!strcmp( (p-next)-Get_end(),pn ) )return 1;p=p-next;return 0;void Bus_link:del()Bus_infor *p,*p2;int num;coutnum;if( !find(&p,num,) )couttt找不到你要删除旳内容!next;p-next=p2-next;delete p2;Bus_link:setkey(1)
14、;void Bus_link:show()Bus_infor *p;p=head;while(p-next)(p-next)-output();p=p-next;void Bus_link:mend()Bus_infor *p;int num=-1;char name20=;coutnum;if( !find1(&p,num,name) )couttt找不到你要修改旳内容!next)-output();(p-next)-input();Bus_link:setkey(1);void Bus_link:save()Bus_infor *p;p=head;ofstream os(bus.txt,i
15、os:out);if (Bus_link:getkey()=1)while(p-next)(p-next)-output(os);p=p-next;coutttt文献已保存! num;is.seekg(t);if(numinput(is);p-next=p2;p2-next=NULL;p=p-next;void Bus_link:clear()Bus_infor *p,*p2;p=head-next;while( p )p2=p;p=p-next;delete p2;char Bus_link:mainmenu()char n6;coutnn -欢迎使用车票管理系统-endlendl;cout
16、 制作人 刘强 endlendl 物理学院 endl endl 1. 录入车票信息 2. 浏览车票信息 endl 3. 查询车票信息 4. 删除车票信息 endl 5. 修改车票信息 6. 定购车票信息 endl 7. 退还车票信息 8. 保存车票信息 endl 0: 退出系统 endl-endl-endln;return n0;int main()Bus_link pp;int k=1;char n;pp.begin(); while(k=1) n=pp.mainmenu(); switch(n) case 1:pp.input(); break; case 2:pp.show(); break; case 3:pp.found(); break; case 4:pp.del(); break; case 5:pp.mend(); break; case 6:pp.Order(); break; case 7:pp.Unorder(); break; case 8:pp.save(); break; case 0: if(pp.getkey()=1) coutk; if(k=1) pp.save(); pp.clear(); k=0; break; return 0;
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100