火车订票管理系统.pdf

上传人:白大夫 文档编号:5591904 上传时间:2020-06-21 格式:PDF 页数:15 大小:153.77KB
返回 下载 相关 举报
火车订票管理系统.pdf_第1页
第1页 / 共15页
火车订票管理系统.pdf_第2页
第2页 / 共15页
火车订票管理系统.pdf_第3页
第3页 / 共15页
火车订票管理系统.pdf_第4页
第4页 / 共15页
火车订票管理系统.pdf_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《火车订票管理系统.pdf》由会员分享,可在线阅读,更多相关《火车订票管理系统.pdf(15页珍藏版)》请在三一文库上搜索。

1、. . 学号 1115 选题三:火车票订票管理系统 1. 基本要求:为方便管理火车票购买信息,编写一个火车票订票管 理系统软件。系统记录必须包括订票人姓名、订票人身份证号、 始发站、终到站、票价、席别、订票时间等。 2. 基本管理功能: 1添加:增加一条订票人的记录到管理系统中。 2查询:根据订票人身份证查找订票人的相关信息并显示,若 找不到也要给出相应提示。 3修改:在管理系统中修改订票人的订票记录。 4保存:将所有订票信息保存在一个文件中(数据库文件或普 通的文本文件)。 5读取:从文件中读取已保存了数据。 6删除:从管理系统中删除一条记录。 7恢复:能恢复被删除的记录。 8统计:(A)

2、统计每天订票张数和总车票金额;(B) 统计单价 在 100 元以下、100400 元之间和 400 元以上的票数总张数 . . 及总金额; (C) 以表格形式打印所有订票信息。 源代码: #include #include #include #include using namespace std; int d;/用于选择 (按 1 继续,按2 退出,按他其他报错待完善) int x=1;/用于脱出while循环 string sfz;/身份证号码,用户输入可用到 class ticket public: string ID; string name; string Sstation; str

3、ing Tstation; float price; string seat; string time; ticket *next; ticket(string I,string n,string S, string T,float p, string s,string t) ID=I;name=n;Sstation=S;Tstation=T;price=p;seat=s;time=t; void display(); ; void ticket:display() coutID=b)che=0;ch=NULL; else ch=ch-next; return che; . . int che

4、ck1(string b)/ sbl ticket *ch; ch=del; int che=1; while(ch!=NULL) if(ch-ID=b)che=0;ch=NULL; else ch=ch-next; return che; int add() /将订票数据保存在一个基础链表中 system(“cls“); float price; string name,ID,Sstation,Tstation,seat,time; if(head=NULL) /以下为链表为空的情况 coutID; coutname; coutSstation; coutTstation; coutpric

5、e; coutseat; couttime; head=p1=p2=new ticket(ID,name,Sstation,Tstation,price,seat,time); x=1; while(x) system(“cls“); coutd; if(d=1) system(“cls“); p1-next=NULL; coutID; if(check(ID)=0)coutname; coutSstation; coutTstation; coutprice; coutseat; couttime; p1=new ticket(ID,name,Sstation,Tstation,price,

6、seat,time); p2-next=p1; p2=p1; else if(d=2) p1-next=NULL; x=0; else coutnext!=NULL) p3=p3-next; x=1; while(x) system(“cls“); coutID; if(check(ID)=0)coutname; coutSstation; coutTstation; coutprice; coutseat; couttime; p0=new ticket(ID,name,Sstation,Tstation,price,seat,time); p3-next=p0; p3=p0; system

7、(“cls“); coutd; if(d=1)x=1;p3-next=NULL; else if(d=2)p3-next=NULL;x=0; else coutID=a) x=0; else cha1=cha1-next; return cha1; ticket *search_1(string a)/改查 1 后面都得改,嗯,就这样了( ) . . ticket *cha1; cha1=del; x=1; while(x) if(cha1=NULL)x=0; else if(cha1-ID=a) x=0; else cha1=cha1-next; return cha1; ticket *s

8、earch2(string b)/查询函数2,返回所要查询结点的前一个结点的指针,在删 除部分使用 ticket *cha2,*cha3; cha2=cha3=head; x=1; while(x) if(cha2-next=NULL)x=0; else if(cha2-ID=b)x=0; else cha3=cha2; cha2=cha2-next; return cha3; ticket *search_2(string b)/ -_- ticket *cha2,*cha3; cha2=cha3=del; x=1; while(x) if(cha2-next=NULL)x=0; else

9、if(cha2-ID=b)x=0; else cha3=cha2; cha2=cha2-next; return cha3; void search() /用于用户查询功能( 目前只能查询一次,然后退出,待完善) system(“cls“); coutsfz; p3=search1(sfz); if(p3=NULL)coutdisplay();system(“pause“); void display1() / system(“cls“); ticket *dis; coutdisplay(); dis=dis-next; while(dis!=NULL); void modify()/修改函

10、数,用于修改数据( 目前只可以修改单个订票信息,待完善) system(“cls“); display1(); coutsfz; p3=search1(sfz); if(p3=NULL) coutd; if(d=1)hui2: coutsfz; if(check(sfz)=0)coutID=sfz; else if(d=2)coutp3-name; else if(d=3)coutp3-Sstation; else if(d=4)coutp3-Tstation; else if(d=5)coutp3-price; else if(d=6)coutp3-seat; else if(d=7)cou

11、tp3-time; else coutd1; if(d1=1)x=1; else if(d1=2)x=0; else coutnext=NULL; else ticket *Dar; Dar=del; while(Dar-next!=NULL) Dar=Dar-next; Dar-next=c; Dar=c; Dar-next=NULL; void Delete()/删除函数将要删除的订票信息移出链表,并将所有删除信息结成另一链表, 供恢复使用 system(“cls“); display1(); coutsfz; p3=search1(sfz); p4=search2(sfz); if(p3

12、=NULL)coutnext;Darea(p3);coutnext=NULL)p4-next=NULL;Darea(p3);coutnext=p3-next;Darea(p3);coutnext; else if(p3-next=NULL)p4-next=NULL; else p4-next=p3-next; void recover()/恢复函数,用于将已经删除的订票信息恢复 system(“cls“); ticket *r1,*r2,*r3; if(del=NULL)coutdisplay(); r1=r1-next; while(r1!=NULL); hui3: coutsfz; if(

13、check1(sfz)=1)coutnext!=NULL)r2=r2-next; r3=search_1(sfz); r2-next=r3; r3-next=NULL; Rdel(sfz); coutdisplay(); dis=dis-next; while(dis!=NULL); system(“pause“); void count()/统计部分 system(“cls“); if(head=NULL)coutprice; n=n+1; m=m+i; if(i=100m3=m3+i; p3=p3-next; coutfilename1; filename1=filename1+“.txt

14、“; 火车票 订票管理系统 savedata“+filename1;/此处路径根据需要自行更改 /*file.open(filename.c_str(),ios:in);/功能失败部分待完善 if(!file) d=1; else d=2; file.close(); if(d=1) file.open(filename.c_str(),ios:out); p1=head; x=1; while(x) if(p1!=NULL) fileIDnameSstationTstationpriceseatt imenext; else x=0; file.close(); couti; if(i=1)

15、 file.open(filename.c_str(),ios:out); . . p3=head; x=1; while(x) if(p3!=NULL) fileIDnameSstationTstationpriceseattimenext; else x=0; file.close(); coutIDnameSstationTstationpriceseattimenext; else x=0; file.close(); coutfilename1; filename1=filename1+“.txt“; 火车票 订票管理系统 savedata“+filename1;/此处路径根据需要自

16、行更改 infile.open(filename.c_str(),ios:in); . . if(!infile) cerrnext=NULL; else L1=head; while(L1-next!=NULL) L1=L1-next; f=atof(aii+4.c_str(); L2=new ticket(aii,aii+1,aii+2,aii+3,f,aii+5,aii+6); L1-next=L2; L1=L2; L1-next=NULL; infile.close(); coutd; if(d=1) add();select(); if(d=2) search();select();

17、 if(d=3) modify();select(); . . if(d=4) Delete();select(); if(d=5) recover();select(); if(d=6) display();select(); if(d=7) count();select(); if(d=8) save();select(); if(d=9) load();select(); else if(d=0) ticket *ex1,*ex2,*ex3,*ex4; ex1=head; while(ex1!=NULL) ex2=ex1; ex1=ex1-next; delete ex2; ex3=del; while(ex3!=NULL) ex4=ex3; ex3=ex3-next; delete ex4; cout_-

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1