一个简单的火车票售票管理系统

上传人:小** 文档编号:113193991 上传时间:2022-06-24 格式:DOC 页数:11 大小:101KB
收藏 版权申诉 举报 下载
一个简单的火车票售票管理系统_第1页
第1页 / 共11页
一个简单的火车票售票管理系统_第2页
第2页 / 共11页
一个简单的火车票售票管理系统_第3页
第3页 / 共11页
资源描述:

《一个简单的火车票售票管理系统》由会员分享,可在线阅读,更多相关《一个简单的火车票售票管理系统(11页珍藏版)》请在装配图网上搜索。

1、一个简单的火车票售票管理系统(原创)#include#include#defineMAX100#defineN50/时间类型/分别对应年,月,日typedefstructtimeintx,y,z;TIME;typedefstructcnodeintno;intid;TIMEdate;structcnode*next;CNODE;/票信息类型/票号/购票人证件号/购票日期typedefstructtnode/车次信息类型chardata;/车次编号structtnode*lchild,*rchild;CNODE*head;TNODE;voidcreate();voidinsert(int);vo

2、iddel();voidinorder(TNODE*);voidinorder_all(TNODE*);voidpreorder(TNODE*);TNODE*search();CNODE*insert_c(CNODE*);CNODE*insert_c_more(CNODE*);CNODE*del_c(CNODE*,CNODE*);CNODE*search_c(CNODE*,int);voidsearch_c_id(CNODE*,int);voidsearch_c_id_all(TNODE*,int);voidsearch_date(CNODE*,TIME);voidsearch_date_al

3、l(TNODE*,TIME);voidprint_c(CNODE*);voidprint_c_all(CNODE*);/按车次建立二叉排序树/增加新的车次(二叉排序树的插入)/取消车次(二叉排序树节点删除)/中序遍历车次二叉排序树(仅显示车次信息)/中序遍历车次二叉排序树(显示车次及售票信息)/先序遍历车次二叉排序树(仅显示车次信息)/按车次编号搜索/插入新的售票信息(单张)/插入新的售票信息(批量)/退票处理(删除售票信息)/按票号查询/按购票人证件号搜索(限定某车次)/按购票人证件号搜索(所有车次)/按购票日期搜索(限定某车次)/按购票日期搜索(所有车次)/输出售票纪录(单张)/输出售票纪

4、录(批量)TNODE*root=NULL;voidmain()inti,func,no,ok;TNODE*t;CNODE*c;TIMEd;printf(nnn);for(i=0;i15;i+)printf(=);printf(列车售票信息管理系统);for(i=0;i15;i+)printf(=);printf(n);printf(t1车次信息管理n);printf(t2售票记录管理n);printf(t3.售票记录查询n);printf(t4.售票记录一览n);printf(t5.退出系统n);for(i=0;in);for(i=0;iN;i+)printf(=);printf(nt1.增加

5、新的车次);printf(nt2.取消车次);printf(nt3.返回上级菜单n);for(i=0;in);for(i=0;iN;i+)printf(=);printf(nt1.增加新的售票记录);printf(nt2.退票);printf(nt3.返回上级菜单n);for(i=0;ihead=insert_c_more(t-head);break;case2:t=search();prints需要退票的票号:);scanf(%d,&no);t-head=del_c(t-head,search_c(t-head,no);break;case3:main();break;default:pri

6、ntf(n错误功能号输入有误!请重新输入!);break;case3:printf(nn售票记录查询n);for(i=0;iN;i+)printf(=);printf(nt1.按票号搜索);printf(nt2.按购票者证件号搜索);printf(nt3.按购票日期搜索);printf(nt4.返回上级菜单n);for(i=0;ihead,no);if(c=NULL)printf(错误没有该票号的纪录!该票还未售出或为废票!自动返回上级菜单n.);break;case2:printf(n请输入您所要查询的购票者证件号:);scanf(%d,&no);search_c_id_all(root,n

7、o);printf(搜索完毕!自动返回上级菜单n.);break;case3:doprintf(n请输入您所要查询的日期(格式:yy-mm-dd):);scanf(%d-%d-%d,&d.x,&d.y,&d.z);if(d.y0)if(d.y=1|d.y=3|d.y=5|d.y=7|d.y=8|d.y=10|d.y=12)if(d.z0)ok=1;elseif(d.z=2)if(d.z0)ok=1;elseif(d.z0)ok=1;elseok=0;if(!ok)printf(n错误日期输入有误!请重新输入!);while(!ok);printf(n指定车次吗?(1-是,0-否):);scan

8、f(%d,&ok);if(ok)search_date(search()-head,d);elsesearch_date_all(root,d);break;case4:main();break;default:printf(n错误功能号输入有误!自动返回上级菜单n.);break;case4:printf(nn售票记录一览n);for(i=0;iN;i+)printf(=);printf(nt1.仅浏览车次);printf(nt2.指定车次已售票记录);printf(nt3.所有车次已售票记录);printf(nt4.测试:先序遍历车次,);printf(nt5.返回上级菜单n);for(i

9、=0;ihead);printf(n);break;case3:printf(n+所有车次已售票记录n);if(root=NULL)printf(错误无车次纪录!);elseinorder_all(root);printf(n);break;case4:printf(n+测试:先序遍历车次n);if(root=NULL)printf(错误无车次纪录!);elsepreorder(root);printf(n);break;case5:main();break;default:printf(n错误功能号输入有误!自动返回上级菜单n.);break;case5:exit(0);default:pr

10、intf(n错误功能号输入有误!请重新输入!);main();voidinorder_all(TNODE*ptr)if(ptr!=NULL)inorder_all(ptr-lchild);printf(%d:n,ptr-data);print_c_all(ptr-head);printf(n);inorder_all(ptr-rchild);voidinorder(TNODE*ptr)if(ptr!=NULL)inorder(ptr-lchild);printf(%dt,ptr-data);inorder(ptr-rchild);voidpreorder(TNODE*ptr)if(ptr!=N

11、ULL)printf(%dt,ptr-data);preorder(ptr-lchild);preorder(ptr-rchild);voidprint_c(CNODE*tkt)if(tkt!=NULL)printf(t%dt%dt%d-%d-%dn,tkt-no,tkt-id,tkt-date.x,tkt-date.y,tkt-date.z);voidprint_c_all(CNODE*head)inti=0,j=0;if(head=NULL)printf(n记录为空!n);return;for(i=0;iN;i+)printf(=);printf(nNOt票号t购票者证件号t购票日期(年-

12、月-日)n);for(i=0;inext;printf(n);for(i=0;iN;i+)printf(-);printf(n总计%d条记录n,j);for(i=0;iN;i+)printf(=);printf(n);voidcreate()intn,i;intkMAX;printf(n您所希望增加车次的数量:);scanf(%d,&n);for(i=0;in;i+)printf(新增第d列车次:,i+1);scanf(%d,&ki);for(i=0;idata=m;root-lchild=root-rchild=NULL;root-head=NULL;elsep1=root;while(m!

13、=p1-data)if(mdata)&(p1-lchild!=NULL)p1=p1-lchild;elseif(mp1-data)&(p1-rchild!=NULL)p1=p1-rchild;elseif(mdata)&(p1-lchild=NULL)p2=(TNODE*)malloc(sizeof(TNODE);p2-data=m;p2-lchild=p2-rchild=NULL;p2-head=NULL;p1-lchild=p2;return;elseif(mp1-data)&(p1-rchild=NULL)p2=(TNODE*)malloc(sizeof(TNODE);p2-data=m

14、;p2-lchild=p2-rchild=NULL;p2-head=NULL;p1-rchild=p2;return;printf(n错误未能成功增加车次%d,车次号%d已存在!,m,m);TNODE*search()intkey;TNODE*p;p=root;printf(n输入您所要查找的车次编号:);scanf(%d,&key);while(p!=NULL&p-data!=key)if(keydata)p=p-lchild;elseif(keyp-data)p=p-rchild;if(p=NULL)printf(n该车次不存在!);return(p);voiddel()intkey;TN

15、ODE*p1,*p2,*p3,*temp;p1=p2=root;p3=temp=NULL;printf(n请输入您想要取消的车次编号:);scanf(%d,&key);while(p2!=NULL&p2-data!=key)if(keydata)p1=p2;p2=p2-lchild;elseif(keyp2-data)p1=p2;p2=p1-rchild;if(p2=NULL)printf(n错误该车次不存在!返回上级菜单n.);return;elseif(p2-lchild=NULL&p2-rchild=NULL)if(p1-lchild=p2)p1-lchild=NULL;if(p1-rc

16、hild=p2)p1-rchild=NULL;temp=p2;if(root=p2)temp=root;root=NULL;elseif(p2-rchild=NULL)temp=p2-lchild;p2-data=temp-data;p2-lchild=temp-lchild;p2-rchild=temp-rchild;elseif(p2-lchild=NULL)temp=p2-rchild;p2-data=temp-data;p2-lchild=temp-lchild;p2-rchild=temp-rchild;elsep3=p2;temp=p2-lchild;while(temp-rchi

17、ld!=NULL)p3=temp;temp=temp-rchild;p2-data=temp-data;if(p3=p2)p3-lchild=temp-lchild;elsep3-rchild=temp-lchild;free(temp);printf(车次%d已取消!nn,key);CNODE*insert_c(CNODE*head)CNODE*k,*p;k=(CNODE*)malloc(sizeof(CNODE);doprintf(n车票编号:);scanf(%d,&k-no);p=search_c(head,k-no);if(p!=NULL)printf(n错误该票已被购买!请重新选择!

18、n);while(p!=NULL);printf(购票者证件号:);scanf(%d,&k-id);prints购票日期(格式:yy-mm-dd):);scanf(%d-%d-%d,&k-date.x,&k-date.y,&k-date.z);k-next=head;head=k;return(head);CNODE*insert_c_more(CNODE*head)intn,i;printf(n请输入批量新增售票记录数:);fflush(stdin);scanf(%d,&n);for(i=0;iid!=id)s=temp;temp=temp-next;print_c(temp);if(tem

19、p!=NULL)return(s);elsereturnNULL;voidsearch_c_id(CNODE*head,intid)CNODE*s,*head_s;s=head_s=NULL;if(head=NULL)printf(无该证件号纪录!n);while(head!=NULL)if(head-id=id)s=(CNODE*)malloc(sizeof(CNODE);s-no=head-no;s-id=head-id;s-date=head-date;s-next=head_s;head_s=s;head=head-next;print_c_all(head_s);printf(n);

20、voidsearch_c_id_all(TNODE*ptr,intid)if(ptr!=NULL)search_c_id_all(ptr-lchild,id);printf(n车次:dn,ptr-data);search_c_id(ptr-head,id);search_c_id_all(ptr-rchild,id);voidsearch_date(CNODE*head,TIMEt)CNODE*s,*head_s;s=head_s=NULL;while(head!=NULL)if(t.x=head-date.x)if(t.y=head-date.y)if(t.z=head-date.z)s=(

21、CNODE*)malloc(sizeof(CNODE);s-no=head-no;s-id=head-id;s-date=head-date;s-next=head_s;head_s=s;head=head-next;print_c_all(head_s);printf(n);voidsearch_date_all(TNODE*ptr,TIMEt)if(ptr!=NULL)search_date_all(ptr-lchild,t);printf(n车次:dn,ptr-data);search_date(ptr-head,t);search_date_all(ptr-rchild,t);CNODE*del_c(CNODE*head,CNODE*p)CNODE*temp;if(p=NULL)printf(错误该票未售出或为废票!返回上级菜单n.);elseif(p=head)head=NULL;free(p);elsetemp=p-next;p-next=temp-next;free(temp);return(head);

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!