#include

#include

#include

#include

int shoudsave=0 ;

int count1=0,count2=0,mark=0,mark1=0 ;

/*定义存储火车信息的结构体*/

struct train

{

char num[10];/*列车号*/

char city[10];/*目的城市*/

char takeoffTime[10];/*发车时间*/

char receiveTime[10];/*到达时间*/

int price;/*票价*/

int bookNum ;/*票数*/

};

/*订票人的信息*/

struct man

{

char num[10];/*ID*/

char name[10];/*姓名*/

int bookNum ;/*需求的票数*/

};

/*定义火车信息链表的结点结构*/

typedef struct node

{

struct train data ;

struct node * next ;

}Node,*Link ;

/*定义订票人链表的结点结构*/

typedef struct people

{

struct man data ;

struct people*next ;

}bookMan,*bookManLink ;

/* 初始界面*/

void printInterface()

{

puts("********************************************************");

puts("* Welcome to use the system of booking tickets *");

puts("********************************************************");

puts("* You can choose the operation: *");

puts("* 1:Insert a train information *");

puts("* 2:Inquire a train information *");

puts("* 3:Book a train ticket *");

puts("* 4:Update the train information *");

puts("* 5:Advice to you about the train *");

puts("* 6:save information to file *");

puts("* 7:quit the system *");

puts("********************************************************");

}

/*添加一个火车信息*/

void InsertTraininfo(Link linkhead)

{

struct node *p,*r,*s ;

char num[10];

r = linkhead ;

s = linkhead->next ;

while(r->next!=NULL)

r=r->next ;

while(1)

{

printf("please input the number of the train(0-return)");

scanf("%s",num);

if(strcmp(num,"0")==0)

break ;

/*判断是否已经存在*/

while(s)

{

if(strcmp(s->data。

num,num)==0)

{

printf("the train '%s'has been born!

",num);

return ;

}

s = s->next ;

}

p = (struct node*)malloc(sizeof(struct node));

strcpy(p->data。

num,num);

printf("Input the city where the train will reach:");

scanf("%s",p->data。city);

printf("Input the time which the train take off:");

scanf("%s",p->data。

takeoffTime);

printf("Input the time which the train receive:");

scanf("%s",&p->data。receiveTime);

printf("Input the price of ticket:");

scanf("%d",&p->data。

price);

printf("Input the number of booked tickets:");

scanf("%d",&p->data。bookNum);

p->next=NULL ;

r->next=p ;

r=p ;

shoudsave = 1 ;

}

}

/*打印火车票信息*/

void printTrainInfo(struct node*p)

{

puts("

The following is the record you want:");

printf(">>number of train: %s

",p->data。

num);

printf(">>city the train will reach: %s

",p->data。city);

printf(">>the time the train take off: %s

the time the train reach: %s

",p->data。

takeoffTime,p->data。receiveTime);

printf(">>the price of the ticket: %d

",p->data。price);

printf(">>the number of booked tickets: %d

",p->data。

bookNum);

}

struct node * Locate1(Link l,char findmess[],char numorcity[])

{

Node*r ;

if(strcmp(numorcity,"num")==0)

{

r=l->next ;

while(r)

{

if(strcmp(r->data。

num,findmess)==0)

return r ;

r=r->next ;

}

}

else if(strcmp(numorcity,"city")==0)

{

r=l->next ;

while(r)

{

if(strcmp(r->data。

city,findmess)==0)

return r ;

r=r->next ;

}

}

return 0 ;

}

/*查询火车信息*/

void QueryTrain(Link l)

{

Node *p ;

int sel ;

char str1[5],str2[10];

if(!l->next)

{

printf("There is not any record !");

return ;

}

printf("Choose the way:

>>1:according to the number of train;

>>2:according to the city:

");

scanf("%d",&sel);

if(sel==1)

{

printf("Input the the number of train:");

scanf("%s",str1);

p=Locate1(l,str1,"num");

if(p)

{

printTrainInfo(p);

}

else

{

mark1=1 ;

printf("

the file can't be found!");

}

}

else if(sel==2)

{

printf("Input the city:");

scanf("%s",str2);

p=Locate1(l,str2,"city");

if(p)

{

printTrainInfo(p);

}

else

{

mark1=1 ;

printf("

the file can't be found!");

}

}

}

/*订票子模块*/

void BookTicket(Link l,bookManLink k)

{

Node*r[10],*p ;

char ch,dem ;

bookMan*v,*h ;

int i=0,t=0 ;

char str[10],str1[10],str2[10];

v=k ;

while(v->next!=NULL)

v=v->next ;

printf("Input the city you want to go: ");

scanf("%s",&str);

p=l->next ;

while(p!=NULL)

{

if(strcmp(p->data。

city,str)==0)

{

r[i]=p ;

i ;

}

p=p->next ;

}

printf("

the number of record have %d

",i);

for(t=0;t

");

scanf("%d",&ch);

if(ch == 1)

{

h=(bookMan*)malloc(sizeof(bookMan));

printf("Input your name: ");

scanf("%s",&str1);

strcpy(h->data。

name,str1);

printf("Input your id: ");

scanf("%s",&str2);

strcpy(h->data。num,str2);

printf("Input your bookNum: ");

scanf("%d",&dem);

h->data。

bookNum=dem ;

h->next=NULL ;

v->next=h ;

v=h ;

printf("

Lucky!you have booked a ticket!");

getch();

shoudsave=1 ;

}

}

}

bookMan*Locate2(bookManLink k,char findmess[])

{。

全部

火车站购票系统c语言编程,用c语言编写火车购票系统怎么编写,在线等,急!!!...相关推荐

  1. 利用Python语言编程,完成猜数游戏,系统随机产生一个1到100的数字num1,用户输入一个数字guess,如果没有猜对,根据系统给出的提示重新猜数,直到才对为止。

    利用Python语言编程,完成猜数游戏,系统随机产生一个1到100的数字num1,用户输入一个数字guess,如果没有猜对,根据系统给出的提示重新猜数,直到才对为止. 要求:(1)系统每次都要给出新的 ...

  2. c语言编程心得,C语言编程心得

    记录这些是为了日后自己想查阅以前经验的方便,同时若能给其他网友带来一些帮助,就更好了~ C语言,自己经常遇到的问题: 1.段错误 段错误一般是由于访问了不存在的地址造成的,具体的原因有文件路径不存在, ...

  3. c语言求三个数最值非函数,C语言编程:从键盘任意输入三个数,编写求其最大值、最小值的函数,用指针作函数参数实现。...

    www.shufadashi.com防采集. C语言编程:从键盘任意输入三个数,编写求其最大值.最小值的函数,用指针作函数参数实现.. #includevoid maxfunction(int*);v ...

  4. c语言中求匀加速直线速度,速求C语言编程题 c语言编程速度求

    导航:网站首页 > 速求C语言编程题 c语言编程速度求 速求C语言编程题 c语言编程速度求 相关问题: 匿名网友: #include //计算行元素和 void CountRow(int a[] ...

  5. 访问外部扩展C语言编程,单片机C语言编程(系统扩展IC)8.ppt

    单片机C语言编程(系统扩展IC)8 第8章 单片机系统扩展 第8章 单片机系统扩展 目 录 8.1 扩展并行三总线 8.2 扩展简单并行输入/输出口 8.3 扩展并行数据存储器 8.4 串行扩展总线接 ...

  6. c语言编程学生对老师的评教系统,记王宇颖教授和她的“C语言”教学团队

    哈工大报讯(刘培香/文) 在计算机学院举行的"我身边的马祖光"征文中,有好几位同学不约而同地写到了同一位老师,字里行间流露的是深深的尊敬和爱戴――"她的每一节课都讲得十分 ...

  7. 动物识别系统c语言编程,人工智能期末论文-简单动物识别系统的知识表示.doc

    简单动物识别系统的知识表示 摘要:动物识别系统是人工智能领域中基础也是非常具有代表性的一个智能系统智能系统最基本的组成部分即知识系统成为了研究热点.本文首先介绍知识系统的基本及作用,以动物识别系统的式 ...

  8. 火车售票系统c语言编程,基于C语言实现简单的12306火车售票系统.pdf

    基基于于C语语言言实实现现简简单单的的12306火火车车售售票票系系统统 程序设计要求用C语言写一个简单的火车售票系统,主要实现的功能为: 入班次信息 浏览班次信息 按班次号查询 按终点站查询 按余票 ...

  9. 海伦公式c语言编程funcd,c语言编程练习题及答案_0.doc

    c语言编程练习题及答案_0 精品文档 2016全新精品资料-全新公文范文-全程指导写作 –独家原创 PAGE1 / NUMPAGES19 c语言编程练习题及答案 学生数 印数 考核方式 闭卷 考核时间 ...

  10. c语言 feof_C语言 实现简单功能的12306火车售票系统【附源码】

    本文福利在文末! 学习迷茫遇到问题了吗?现在关注微信公众号:C程序编程 免费获取进阶指导,资料工具以及源码 程序设计要求用C语言写一个简单的火车售票系统,主要实现的功能为: 录入班次信息 浏览班次信息 ...

最新文章

  1. 三分钟教你快速选择机器视觉传感器
  2. python network_python network(非常好)
  3. 自制树莓派“防松鼠神器”在Reddit火了,13行代码就能让AI替你护食,成本300+元...
  4. 19道小米网运维工程师笔试真题
  5. 【NLP】全方位解读 | Facebook的搜索是怎么做的?
  6. bat判断文件是否存在_BAT面试必问题系列:JVM判断对象是否已死和四种垃圾回收算法总结...
  7. 《数据库原理与应用》(第三版) 第7章 索引和视图 基础 习题参考答案
  8. 【转】增量式PID控制算法
  9. 王道 —— 操作系统的运行机制和体系结构
  10. 三星Galaxy S22系列快充规格曝光:只可比肩iPhone 13Pro Max
  11. SSAS的MDX的基础函数(三),及聚合函数
  12. h5物体拖动_html5实现拖拽效果
  13. c调用python函数_python - Linux C调用Python 函数
  14. ros 机械臂复位_ROS入门学习之八机器人综合应用
  15. 大话西游版《我叫小沈阳》
  16. matlab二维傅里叶变化并得到频谱,图像的二维傅里叶变换和频谱
  17. 车机中行车记录仪(DVR)MVP模式开发总结
  18. 多态 继承 封装 打印输出长方形 正方形 圆形的周长和面积
  19. macOS Outlook 查看邮件的源码 HTML源码
  20. opencv-pythons实现图像周长面积(三角形)检测DIY整理

热门文章

  1. 论文被拒怎么办?(下)
  2. 利用深度学习的点云语义分割(一)
  3. 区块链研习 | 什么是区块链的链外交易和链内交易
  4. JAVA获取当前系统时间System.currentTimeMillis()
  5. 《JAVA与模式》之责任链模式
  6. asp.net网站安全常见问题与防范
  7. 虚拟化部署之Hyper-V虚拟网络配置
  8. SQL Server2005如何进行数据库定期备份(转)
  9. 【C/C++语言入门篇】-- 文件操作
  10. 读张鸣-《辛亥:摇晃的中国》感