火车票查询系统编程代码(火车票编号查询系统)
admin 发布:2022-12-19 18:54 146
本篇文章给大家谈谈火车票查询系统编程代码,以及火车票编号查询系统对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、如何查询火车票售票点行政编码?
- 2、c语言车票订购系统
- 3、、求C语言程序 票务信息管理程序 基本要求: 1.要求实现查询车票、购买车票、退订车票和退
- 4、Python 实现一个火车票查询的工具
- 5、python 火车票查票的代码 其中 e=re.findall('%s\|([^|]+)' % e,cont)[0]
如何查询火车票售票点行政编码?
一、火车票下面编码说明:
1、编码组成:
火车票最下方,在条形码的下面有一串数字和字母的组合。
2、其中的含义是:
(1)第1-5位数字表示发售车票的车站代码,例如京B代码是21152,京D代码是12713,清华园,代码是12710。
(2)第6位代表售票点类型,0表示车站售票处,2表示代售点,所以京A售就对应100010,京AD售对应100012,京B售对应211520,京BD售对应211522,京D售对应127130。
(3)第7-10位数字表示售票窗口的编号。例如清华园售对应1271000001。
(4)第11-14位数字表示出售车票的日期。
(5)最后4位数字是车票上起点站到终点站之间的里程,例如Z85次北京到苏州是1379公里。
c语言车票订购系统
#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!\n",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("\nThe following is the record you want:");
printf("number of train: %s\n",p-data.num);
printf("city the train will reach: %s\n",p-data.city);
printf("the time the train take off: %s\nthe time the train reach:
%s\n",p-data.takeoffTime,p-data.receiveTime);
printf("the price of the ticket: %d\n",p-data.price);
printf("the number of booked tickets:
%d\n",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:\n1:according to the number of
train;\n2:according to the city:\n");
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("\nthe 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("\nthe 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("\n\nthe number of record have %d\n",i);
for(t=0;t
printTrainInfo(r[t]);
if(i==0)
printf("\n\t\t\tSorry!Can't find the train for you!\n");
else
{
printf("\ndo you want to book it?1/0\n");
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("\nLucky!you have booked a ticket!");
getch();
shoudsave=1 ;
}
}
}
bookMan*Locate2(bookManLink k,char findmess[])
{
bookMan*r ;
r=k-next ;
while(r)
{
if(strcmp(r-data.num,findmess)==0)
{
mark=1 ;
return r ;
}
r=r-next ;
}
return 0 ;
}
/*修改火车信息*/
void UpdateInfo(Link l)
{
Node*p ;
char findmess[20],ch ;
if(!l-next)
{
printf("\nthere isn't record for you to modify!\n");
return ;
}
else
{
QueryTrain(l);
if(mark1==0)
{
printf("\nDo you want to modify it?\n");
getchar();
scanf("%c",ch);
if(ch=='y');
{
printf("\nInput the number of the train:");
scanf("%s",findmess);
p=Locate1(l,findmess,"num");
if(p)
{
printf("Input new number of train:");
scanf("%s",p-data.num);
printf("Input new city the train will reach:");
scanf("%s",p-data.city);
printf("Input new time the train take off");
scanf("%s",p-data.takeoffTime);
printf("Input new time the train reach:");
scanf("%s",p-data.receiveTime);
printf("Input new price of the ticket::");
scanf("%d",p-data.price);
printf("Input new number of people who have booked ticket:");
scanf("%d",p-data.bookNum);
printf("\nmodifying record is sucessful!\n");
shoudsave=1 ;
}
else
printf("\t\t\tcan't find the record!");
}
}
else
mark1=0 ;
}
}
/*系统给用户的提示信息*/
void AdvicedTrains(Link l)
{
Node*r ;
char str[10];
int mar=0 ;
r=l-next ;
printf("Iuput the city you want to go: ");
scanf("%s",str);
while(r)
{
if(strcmp(r-data.city,str)==0r-data.bookNum200)
{
mar=1 ;
printf("\nyou can select the following train!\n");
printf("\n\nplease select the fourth operation to book the ticket!\n");
printTrainInfo(r);
}
r=r-next ;
}
if(mar==0)
printf("\n\t\t\tyou can't book any ticket now!\n");
}
/*保存火车信息*/
void SaveTrainInfo(Link l)
{
FILE*fp ;
Node*p ;
int count=0,flag=1 ;
fp=fopen("c:\\train.txt","wb");
if(fp==NULL)
{
printf("the file can't be opened!");
return ;
}
p=l-next ;
while(p)
{
if(fwrite(p,sizeof(Node),1,fp)==1)
{
p=p-next ;
count++;
}
else
{
flag=0 ;
break ;
}
}
if(flag)
{
printf("the number of the record which have been saved is %d\n",count);
shoudsave=0 ;
}
fclose(fp);
}
/*保存订票人的信息*/
void SaveBookmanInfo(bookManLink k)
{
FILE*fp ;
bookMan*p ;
int count=0,flag=1 ;
fp=fopen("c:\\man.txt","wb");
if(fp==NULL)
{
printf("the file can't be opened!");
return ;
}
p=k-next ;
while(p)
{
if(fwrite(p,sizeof(bookMan),1,fp)==1)
{
p=p-next ;
count++;
}
else
{
flag=0 ;
break ;
}
}
if(flag)
{
printf("the number of the record which have been saved is %d\n",count);
shoudsave=0 ;
}
fclose(fp);
}
int main()
{
FILE*fp1,*fp2 ;
Node*p,*r ;
char ch1,ch2 ;
Link l ;
bookManLink k ;
bookMan*t,*h ;
int sel ;
l=(Node*)malloc(sizeof(Node));
l-next=NULL ;
r=l ;
k=(bookMan*)malloc(sizeof(bookMan));
k-next=NULL ;
h=k ;
fp1=fopen("c:\\train.txt","ab+");
if((fp1==NULL))
{
printf("can't open the file!");
return 0 ;
}
while(!feof(fp1))
{
p=(Node*)malloc(sizeof(Node));
if(fread(p,sizeof(Node),1,fp1)==1)
{
p-next=NULL ;
r-next=p ;
r=p ;
count1++;
}
}
fclose(fp1);
fp2=fopen("c:\\man.txt","ab+");
if((fp2==NULL))
{
printf("can't open the file!");
return 0 ;
}
while(!feof(fp2))
{
t=(bookMan*)malloc(sizeof(bookMan));
if(fread(t,sizeof(bookMan),1,fp2)==1)
{
t-next=NULL ;
h-next=t ;
h=t ;
count2++;
}
}
fclose(fp2);
while(1)
{
system("cls");
printInterface();
printf("please choose the operation: ");
scanf("%d",sel);
system("cls");
if(sel==8)
{
if(shoudsave==1)
{
getchar();
printf("\nthe file have been changed!do you want to save it(y/n)?\n");
scanf("%c",ch1);
if(ch1=='y'||ch1=='Y')
{
SaveBookmanInfo(k);
SaveTrainInfo(l);
}
}
printf("\nThank you!!You are welcome too\n");
break ;
}
switch(sel)
{
case 1 :
InsertTraininfo(l);break ;
case 2 :
QueryTrain(l);break ;
case 3 :
BookTicket(l,k);break ;
case 4 :
UpdateInfo(l);break ;
case 5 :
AdvicedTrains(l);break ;
case 6 :
SaveTrainInfo(l);SaveBookmanInfo(k);break ;
case 7 :
return 0;
}
printf("\nplease press any key to continue.......");
getch();
}
return 0;
}
、求C语言程序 票务信息管理程序 基本要求: 1.要求实现查询车票、购买车票、退订车票和退
System.out.println("a == b : " + (a == b.intValue()));
System.out.println("b ==c : " + (b == c));
System.out.println("e == (c + d) : " + (e.intValue() == c.intValue() + d.intValue()));
System.out.println("e.equals(c + d) : " + e.equals(Integer.valueOf(c.intValue() + d.intValue())));
System.out.println("h == (c + d) : " + (h.longValue() == c.intValue() + d.intValue()));
System.out.println("h.equals(c + d) : " + h.equals(Integer.valueOf(c.intValue() + d.intValue())));
System.out.println("f == g : " + (f == g));
System.out.println("m == n : " + (m == n));
System.out.println("p == q : " + (p == q));
System.out.println("m == d * 2 : " + (m.doubleValue() == d.intValue() * 2));
System.out.println("p == (d + e) : " + (p.floatValue() == d.intValue() + e.intValue()));
Python 实现一个火车票查询的工具
使用 python 实现一个查询火车票的小工具
主要功能:
输入出发车站,到达车站,时间,然后返回所有的车次信息,和余票信息
支持输入附加选项查询不同的火车的类型,比如高铁,动车。
#查询上海到北京2017-04-25的高铁和动车的车票,-g -d 是附加选项 表示高铁和动车
python3 trains.py -gd 上海 北京 2017-04-25
运行结果:
1. 对12306网站买票过程抓包分析
点击查询之后,通过抓包发现返回了一个json的文件,查看这个文件,就是保存着具体车次的信息。抓包如下图所示。
请求的url 是:
GET /otn/leftTicket/query?leftTicketDTO.train_date=2017-04-20leftTicketDTO.from_station=TJPleftTicketDTO.to_station=TYVpurpose_codes=ADULT HTTP/1.1
发现这个请求使用的是get方法,然后传递了四个参数,一个是出发站,一个是到达车站,一个是成年人or学生,最后一个是时间。如下图:
但是有一个问题是,我输入的是天津到太原,但是这个却转换成了拼音的简称。必须要找到这个转换的字典是什么,这样才能正确的使用这个接口。
在网页的源代码找到这个文件,station_name.js 文件,如下图:
js文件的格式是,如下图,使用的话,必须要想用正则表达式处理一下:
2. 使用正则表达式处理这个js文件
使用正则表达式,将js 文件里面的车站名字和对应的简称提取出来,然后写入到一个station.py 文件里面,作为字典,程序运行的时候,将这个文件以模块的形式包含进去。
关于正则表达式,先占一个坑,以后在详细的写。
正则表达式的代码:
运行的时候:
# 将输出重定向到一个新的文件stations.py里面python3 test3.py stations.py
3. 使用docopt 优雅的完成命令行的输入
docopt 是一个很优雅的处理输入的一个模块,docopt可以根据你写的文档描述,可以自动为你生成解析器,可以非常容易的为你的python程序创建命令行界面。
4. 主程序
4.1 处理url
4.2 输出
运行结果:
5. 使用prettytable模块 优雅的输出
详细:
作者 sexycoder 本文转载自简书,转载需授权
python 火车票查票的代码 其中 e=re.findall('%s\|([^|]+)' % e,cont)[0]
'%s\|([^|]+)' % e
这是" 格式化字符串%参数 "的形式 '%s\|([^|]+)' 是用于格式化的字符串,%e e是参数
%s表示将e作为字符串打印 '\|([^|]+)' 于'|([^|]+')相同,如e 为hello,这个字符串就是
'hello|([^|]+)' 这就是实际传给findall的正则表达式,这样正则就不对吧
如果字符串前有r才对吧,e=re.findall(r'%s\|([^|]+)' % e,cont)[0] ,这样提取findall查找到的列表中下标为0的第一个值
关于火车票查询系统编程代码和火车票编号查询系统的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:网页左右切换效果代码(html网页切换效果)
- 下一篇:关于通栏css代码的信息
相关推荐
- 05-09网页代码,网页代码快捷键
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
- 05-06在线html执行代码(html怎么运行)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06代码源软件库(程序代码库)[20240506更新]
- 05-06点击弹出密码代码(点击弹出密码代码错误)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接