火车票查询系统代码
- 格式:pdf
- 大小:86.80 KB
- 文档页数:8
#include<conio.h>#include<stdio.h>#include<stdlib.h>#include<string.h>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];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:\n>>1:according to the number of train;\n>>2: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<i; 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->, 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;}elseprintf("\t\t\tcan't find the record!");}}elsemark1 = 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) == 0 && r->data.bookNum < 200){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("D:\\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("D:\\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("D:\\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("D:\\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;}。
火车票查询系统摘要随着网络时代的快速发展,中国网民人数的持续增加,电子商务的普及以及中国现代物流的飞速发展,互联网法律法规的逐步完善,电子商务的环境已经初步形成,网上购物系统作为电子商务的一种主要实现形式必将得到进一步的普及和应用。
该系统主要为用户提供了会员注册、网上查询等功能;在设计方面,系统是典型的电子商务平台, 其开发基于B/S模式的网上销售的实现,采用的是ASP + ACCESS 模式。
该系统设计上采用三层结构、Web Service技术,使之在选用平台、采用技术上具有先进性、前瞻性、扩充性,从而保证建成的系统具有良好的稳定性、可扩充性。
从功能上来说,系统是比较完备的,系统以Web界面与用户交互,为用户提供信息并接受其操作,同时通过数据库管理系统来存储信息数据。
系统实现了对信息数据的浏览、查询、编辑和管理等基本数据库操作,采用了模块化设计方法,根据用户的需求及程序的应用与维护的易用性,将各个部分置于不同的模块当中,方便了程序的扩展与维护,同时建立了程序功能复用的基础。
本文所做火车票网上查询系统是一个根据现有的网上查询系统的现状而设计开发的电子商务平台,可以减少成本,提高工作效率。
关键词:网上查询;电子商务;ASP;交互AbstractWith the increasing number of netizens, the emergence of third--party payment means as well as the rapid development of modern logistic and the improvement of laws and regulations, the environment of e-commerce has formed in china. The shop online system which acted as one way to implement of electronic commerce will become more and more popular in the future.This system mainly to provide users with a registered member, preview tourist attractions, tickets online, provides the ticket for the administrator management, customer information management and information management, advertising spots link management etc. Function. In the design, system is a typical e-commerce sales platform, its development based on B/S model, online sales by ASP + ACCESS mode. Choose ACCESS database of backstage supporter's database. This system is used on three-layer structure design, Web Service technology, make in selecting, using the platform with advanced technology, prospectie, expand, and ensure the completion of the system has a good stability and extensibility. Using software component, system structure, development, business and separated, logic and data: In a unified service interface standard as the core, the use of open standards. From the function, system is relatively complete system with Web interface and the user interaction, and provide information and accept its operation, and through a database management system to store information and data. System of data to browse, query, editing and management database, the basic operating modular design methods, according to user's requirements and procedures of application and maintenance of facility, and the different parts will be placed among modules, convenient maintenance and expansion of the program, and established the basic program function reuse.The tourist attractions do online ticketing system is an online ticketing system according to the current situation of the development and design of e-commerce platform. It not only can expand the scale and influence the market business, and can reduce the operating costs, improve work efficiency.Key words:Online ticketing; e-commerce;ASP; interacti目录1绪论 (4)1.1课题现状 (4)1.2课题开发目的 (4)1.3课题关键技术 (5)1.3.1 ASP简介 (5)1.3.2 Dreamweaver (5)1.3.3 ACCESS (6)1.3.4 HTML(Hyper Text Markup Language) (6)2 可行性研究 (6)2.1资源可行性 (7)2.2技术可行性 (7)2.3经济可行性 (7)2.4社会的可行性 (7)3 系统需求分析 (8)3.1目标和任务 (8)3.2系统功能分析 (8)3.2.1 查询功能分析 (8)3.2.2 网站的界面设计 (8)3.3网站业务流程 (9)3.3.1 火车票网上查询系统的业务流程介绍 (9)3.3.2 系统的设计流程图 (9)4 系统概要设计 (10)4.1系统结构设计目标 (10)4.1.1 系统HIPO图 (10)4.1.2 系统功能模块介绍 (11)4.1.2.1登录模块 (11)4.1.2.2 注册模块 (11)4.1.2.3查询模块 (11)4.1.2.4用户管理模块 (11)4.2数据库结构设计 (11)4.2.1 数据库概念结构设计 (11)4.2.2数据库逻辑结构 (13)5 系统详细设计 (14)5.1系统总体结构图 (14)5.2过程设计 (15)5.2.1.系统用户权限的系统主处理流程 (16)5.2.2.车次信息查询处理流程 (17)6 系统运行与测试 (18)6.1系统调试 (18)6.2测试与运行 (18)6.2.1.系统管理员登陆首页 (18)6.2.2系统用户登陆注册首页 (19)6.2.3.车次查询界面 (19)6.2.4.车次查询结果 (20)结束语 (20)致谢 (21)参考文献 (21)附录 (21)1 绪论网上查询,相对于传统查询方式而言,是随着现代信息技术的发展而产生的一种新型查询方式,是一种消费者和工作人员分离的、非面对面的查询方式,是一种跨地区的查询模式。
火车票售票系统一、实验目的:1、熟练掌握数据库设计原理及模型构建软件PowerDesignerd 的使用。
2、熟练掌握Visual Studio 2008的使用。
3、实现方便、快捷使用火车票购票系统查票、购票、退票等功能。
4、实现系统的安全性设置,使系统具有一定的维护功能。
二、实验设备及软件:PC 机一台、Visual Studio 2008、SQL SERVER 2000三、需求分析: 3.1 功能分析:功能模块图教师评阅意见:签名: 年 月 日实验成绩:火车票售票系统新用户注册 购票 、预约余 票 查询 退 票 票价查询1、新用户注册模块:新用户注册需要新用户填入自己的基本信息包括用户名、密码和确认密码),详细的购票需要信息(包括姓名、性别、出生日期、证件类型、证件号码)以及联系方式(包括手机号码、电子邮箱、地址),只有当所有的信息格式填写正确和填写完全后才能注册成功。
2、购票/预订模块:购票/预订模块需要用户登录后,输入需要购票的出发站、目的站和出发日期后即可显示可购票,选择自己需要的票即可购票,点击购票则购票成功。
3、余票查询模块:余票查询模块需要用户在登录进入售票系统后点击余票查询按钮,按照要求填入出发地、目的地,选择出发日期,选择填入出发车次,完成输入后即可在界面下方看到所有满足要求的查询结果。
4、退票模块:退票模块需要用户在登录后,进入退票界面,即可显示登录用户所有订单,选择需要退票的订单,点击退票按钮即可退票。
5、票价查询模块:票价查询模块同样需要用户在登录进入售票系统后点击余票查询按钮,按照要求填入出发地、目的地,选择出发日期,选择填入出发车次,完成输入后即可在界面下方看到所有满足要求的查询结果。
3.2 流程图:火车票售票系统业务流程图如下图所示:1、新用户注册及登录流程图:新用户填写失败注册信息提交注册成功2、购票/预订流程图:填写失败成功2、余票查询流程图:填写显示3、退票流程图:登陆失 败 显示成功 出 发 站 目 的 站 出 发 日 期 用 户购 票 用 户 出 发 站 目 的 站 出 发 日 期 余 票 信 息用 户 退票界面所 有 订 单 退 票4、票价查询流程图:用户登陆票价查询显示车票票价四、数据库结构设计:4.1 E-R模型的建立:E-R模型由新用户注册、登录界面、购票、余票查询、票价查询这五个实体构成。
12306回参解析
12306是中国铁路客户服务中心的官方网站,用于购买火车票和查询相关信息。
回参解析是指对12306网站返回的数据进行解析和处理的过程。
在12306网站上,用户进行车票查询、购票等操作后,系统会返回一段数据,通常是以JSON格式或HTML格式呈现。
回参解析的目的是提取有用的信息,如车次、出发时间、到达时间、座位信息等,并将其展示给用户或进行进一步的处理。
回参解析需要考虑以下几个方面:
1. 数据格式解析,根据返回的数据格式,如JSON或HTML,使用相应的解析方法进行数据提取。
对于JSON格式,可以使用JSON 解析库将数据转化为可操作的对象;对于HTML格式,可以使用HTML解析库进行解析。
2. 数据字段提取,根据业务需求,确定需要提取的字段,并编写相应的代码进行字段提取。
例如,需要提取车次信息,则可以通过遍历数据对象的方式提取出所有的车次信息。
3. 数据清洗和处理,有时候返回的数据可能存在噪声或不完整的情况,需要进行数据清洗和处理。
例如,对于时间字段,可能需要进行格式化或转换为特定的时间格式。
4. 错误处理,在回参解析过程中,可能会出现一些错误,如网络请求失败、数据格式异常等。
需要编写相应的错误处理代码,以确保程序的稳定性和可靠性。
总之,回参解析是对12306网站返回数据的处理过程,通过解析和提取有用的信息,为用户提供准确、完整的车票查询和购票服务。
12306实时余票查询接口代码文档及返回示例在即将到来的双十二,在聚合数据平台上的12306实时余票查询接口将参与“暖冬不如低价活动”,主打汽车和金融两类数据接口。
此次我们将分享下12306实时余票查询接口代码文档及返回示例,可查询实时火车票余票,包括车次、车次始发站、车次终点站、出发时间、到达时间、车次类型、总历时时间等等。
接口名称:12306实时余票查询接口接口平台:聚合数据接口地址:/train/yp支持格式:JSON/XML请求方式:HTTP GET/POST请求示例:/train/yp?key=申请的KEY&dtype=json&from=%E4%B8%8A%E6%B5%B7%E8%99%B9%E6%A1%A5&to=%E6% B8%A9%E5%B7%9E&date=2014-06-28&tt=接口备注:火车余票查询12306实时余票查询接口调用代码JSON返回示例:{"reason": "查询成功","result": [{"train_no": "D2287", /*车次*/"start_station_name": "上海虹桥", /*车次始发站*/"end_station_name": "深圳北", /*车次终点站*/"from_station_name": "上海虹桥", /*出发站*/"to_station_name": "温州南", /*到达站*/"start_time": "06:25", /*出发时间*/"arrive_time": "10:53", /*到达时间*/"train_class_name": "动车", /*车次类型*/"day_difference": "0", /*历时天数*/"lishi": "04:28", /*总历时时间*/"gr_num": "--", /*高级软卧:-- 说明无该席位*/"qt_num": "--", /*其他*/"rw_num": "--", /*软卧*/"rz_num": "--", /*软座*/"tz_num": "--", /*特等座*/"wz_num": "无", /*无座*/"yw_num": "--", /*硬卧*/"yz_num": "--", /*硬座*/"ze_num": "无", /*二等座*/"zy_num": "无", /*一等座*/"swz_num": "--" /*商务座*/ },{"train_no": "D3203","start_station_name": "上海虹桥","end_station_name": "厦门北","from_station_name": "上海虹桥","to_station_name": "温州南","start_time": "06:30","arrive_time": "11:09","train_class_name": "动车","day_difference": "0","lishi": "04:39","gr_num": "--","qt_num": "--","rw_num": "--","rz_num": "--","tz_num": "--","wz_num": "无","yw_num": "--","yz_num": "--","ze_num": "无","zy_num": "无","swz_num": "--"},{"train_no": "G7501","start_station_name": "上海虹桥","end_station_name": "苍南","from_station_name": "上海虹桥","to_station_name": "温州南","start_time": "07:00","arrive_time": "11:00","train_class_name": "","day_difference": "0","lishi": "04:00","gr_num": "--","qt_num": "--","rw_num": "--","rz_num": "--","tz_num": "--","wz_num": "165","yw_num": "--","yz_num": "--","ze_num": "无","zy_num": "无","swz_num": "15"}],"error_code": 0}。
国内各火车站代码
以上是国内一些常见火车站的代码列表,这些代码是通过国家铁路总公司统一设定的标识符,用于区分各个火车站。
每个火车站的代码都是独一无二的,方便人们在购票、查询信息时使用。
火车站代码通常由两个字母组成,代表着火车站的名称。
这些代码既可以用于火车票的购买和使用,也可以用于车站的识别和查询。
以北京站为例,其代码为BJ。
当您购买火车票时,可以在购票系统中输入BJ作为目的地代码,系统会自动识别您希望购买去往北京站的车票。
同样地,当您需要了解北京站的列车时刻表、车站位置等信息时,可以输入BJ进行查询。
火车站代码对于铁路运输的管理和运营也非常重要。
通过代码的标识,铁路部门可以高效地进行车票销售、列车调度、站内管理等工作。
车站代码的使用使得信息传递更加准确和便捷。
需要注意的是,虽然这份文档列举了一些常见火车站的代码,但并不代表全部。
中国境内有众多火车站,每个火车站都有自己的代码。
如果您需要查询其他火车站的代码,可以通过官方网站或相关应用程序进行查询,或者咨询售票窗口或客服人员。
火车站代码的标准化使用对旅客和铁路部门都具有重要意义。
通过统一的代码,旅客可以方便地购票、查询信息,并且减少因为乘车目的地名称不同而产生的混淆和错误。
铁路部门也可以更高效地进行管理和运营,提供更好的服务。
希望这份国内各火车站代码文档能为您提供帮助,让您在购票和查询火车信息时更加便捷和准确。
如有任何疑问或需要进一步的信息,请随时与我们联系。