火车票管理系统总代码
- 格式:doc
- 大小:130.50 KB
- 文档页数:17
t\t\t#include /z stdio. h〃 #include /z stdlib ・ h 〃 #include z/string. hV*定义头文件,处理文件及字符数组时要用到相应功能 #define N 10 void fmenu() (system(〃cls 〃); printf("************************ vl.20*****************\n 〃); 查询列车 %cl. */欢迎使用苏州列车时刻表信息管理系统 printf(〃\t\ \n\ 3) t\t\t printf (z/\n ,z %c2. 修改列车 \n\ 3)); printf (〃\t\ %c3. 增加列车\n\ 3) printf CW %c4. 取消列车 \n\ 3) ); printf("\t\ t\t\t printf C\n z/ ); , %c5. %c0. 保存信息 \n\ 3) r aX* f viz K I X K I Z K I X x/z K I Z K I ZI I printf (,z \ t\***********、□"); t\t\tprintf j ; if 选择要执行的操作:\n 〃);/*菜单程序,用于各种功能的选择*/ ' struct train/*定义结构体*/ ); phiiatfi4rn^fS]; t't'tchar checi[6];旺l 吁翦;yr ); tint month; printf (〃\t\int day; t\t\t int hour; int minute; } lieche[N] ;/* 定义一个结构体数组 */ void paixu(struct train *p) ;/* 函数声明 */ void chaxun(struct train *p)/*子程序,其功能是查询列车*/ ( paixu(lieche) ;/*先排序一下,方便查看*/ char a[8] ;/*定义一个字符数组,输入要查 询的列车 int k=0, i, c; */ printf ("请输入要查询的列车:\n 〃); scanf ("%s", a); for(i=0;i<N;i++)if (strcmp(p[i]・ name, a) ==0)printf (,z苏州一%s\t%s (车次)\t%d 年%d\t%d:%02d\n,\ p[i]・name, p[i]・checi, p[i]・year, p[i]・month, p_i]・day, p[i]・hour, p[i]・minute) ;/*车的信息全部打出*/k++;)if(k==0)printf (z/抱歉,没有这趟列车\n〃);/*没有查到时,打出通知*/ printf C按1继续,按0退出\『);/*选择继续或者退出*/ scanf(〃%d〃,&c);if(c!=0)chaxun(lieche);void xiugai (struct train *p)/*子程序,用于修改列车时间*/(char a[8], b [6];int i, x, c, k二0, h, mi, y, m, d, q;printf(〃请输入要修改的列车:\n〃);scanf ("%s", a);for(i=0;i<N;i++)(if (st rcmp (p[i ]・ name, a) =0)printf (z,苏州一%s\t%s ()车次\t%d 年%d\t%d:%02d\n,/, p[i]・ name, p[i]・ checi, p[i]. year, p[i]・ month, p.i]・ day, p[i]・ hour, p[i]・ minute)fprintf (”要修改这趟列车吗?\nl.是0.否\n〃);scanf &q); if (q==l)printf ("请输入修改后的车次:\n,z) ; scanf ("%s", b);printf ("请输入修改后的年月日:\n") ; scanf (“%d%d%d", &y, &m, &d);scanf ("%d%d〃, &h, &mi);printf C确定修改吗?\nl.是2.否\n〃);/*选择是否确定修改列车时%d日将所间,防止查列错误操作*/scan f ("%d〃,&x);if (x=l)(strcpy (p[i]・ checi, b); p[i]. yearly;%d日p[i]・ month二m; p[i]. day=d; p[i]・ hour=h; p[i]・ minute二mi; printfC己经修改此列车〃);k++;)} if(k==0)printf(z,抱歉,没有这趟列车\n〃);/*没有查到时,打出通知*/ printf C按]继续,按scanf &c) ;0 退出\n");if(c!=0)xiugai(lieche);void zengjia(struct train 子程序,用于列车增加*/*p) /*(struct train a;char 空白位置,在此处插入所填列车*/b □二{〃0000000〃} ;/*printf (〃请输入要增加的列车目的地:\『);scanf ("%s", a. name);printf(〃请输入修改后的车次:\rT);scanf a. checi);printf (〃请输入所增加列车的年月日:\『);scanf ("%d%d%d", &a. year, &a. month, &a. day);printf(〃请输入所增加列车的小时和分钟:\n〃);scanf ("%d%d", &a. hour, &a. minute);printf (”确定要增加这一趟列车吗?\nl.是0.否\n〃);scanf&x);if(x==l) for(i=0;i<N-l;i++)if (strcmp (p[i]・ name, b) =0)(strcpy (p[i]・ name, a. name) ; strcpy (p[ij. checi, a. checi);p[i]. year=a・ year;p[i]・ month=a・ month; p[i]・ day=a・ day; p[i]・ hour=a・ hour;p[i]・ minute=a・ minute;strcpy (pli+l]. name, b) ;/*找到位置,插入列车,并把0000000给后面一个结构体*/printfC已经增加这趟列车“);break;5 paixu(lieche) ; printf (〃按 1 继续,按0 退出\n") ; scanf ("%d", &c); if(c!=0) zengjia(lieche); } voidpaixu(struct train *p)/*子程序,用于同名列车时刻排序*/ int i, x; char a[6];for(i=0;i<N;i++)if (strcmp(p[i]. name, p[i+l]. name)==0)/* 先找到相同名字的列车*/ if (p[iJ. year>p[i+l]. year)// 根据年份排序(strcpy (a, p[i]・ checi);strcpy (p[i]・ checi, p[i+l]・ checi);strcpy(p[i+l]. checi, p[i[・ checi) ; x二p[i]・ year; p[i]・ year=p[i+l]. year;p[i+l]. year=x;x=p[i]・ month;p[i]・ month二p[i+l]・ month;p[i+l]・ month二x;x二p[i]. day;p[i]. day=p[i+l]. day;p[i+l]・ day=x;x二p[i]・ hour;p[i]・ hour二p[i+l]. hour;p[i+l]・ hour=x;x二p[i]. minute;p[i]. minute=p[i+l]・ minute;p[i+l]. minute二x;else if(pLi]・year二二p[i+l].year)if (p[i]. month>p[i+l]. month)// 相同年数,根据月份排序。
车票管理系统详细说明:1.程序功能一车站每天有n个发车班次,每个班次都有一班次号(1、2、3、…、n),固定的发车时间,固定的路线(起始站、终点站),大致的行车时间,固定的额定载客量。
如:班次发车时间起点站终点站行车时间额定载量已定票人数1 8:00 重庆昆明 10 45 302 6:30 重庆成都 4 40 403 7:00 重庆成都4 40 204 10:00 重庆成都 4 40 2……现要求设计一个管理系统,能完成如下功能:(1)录入班次信息(信息用文件保存),可不定时地增加班次数据;(2)浏览班次信息,可显示出所有班次当前状况(如果当前系统时间超过了某班次的发车时间,则显示"此班已发出"的提示信息);(3)查询路线:可按班次号查询,也可按终点站查询;(4)售票和退票功能。
①:当查询出已定票人数小于额定载量且当前系统时间小于发车时间时才能售票,自动更新已售票人数;②:退票时,输入退票的班次,当本班车未发出时才能退票,自动更新已售票人数。
2.设计思想此系统可参照学生成绩管理系统的部份设计方法而设计。
1车票管理系统车票管理系统一车站每天有n个发车班次,每个班次都有一班次号(1、2、3…n),固定的发车时间,固定的路线(起始站、终点站),大致的行车时间,固定的额定载客量。
如班次发车时间起点站终点站行车时间额定载量已定票人数1 8:00 郫县广汉2 45 302 6:30 郫县成都0.5 40 403 7:00 郫县成都0.5 40 204 10:00 郫县成都0.5 40 2…(一)功能要求:用c/c++设计一系统,能提供下列服务:(1)录入班次信息(信息用文件保存),可不定时地增加班次数据(2)浏览班次信息,可显示出所有班次当前状态(如果当前系统时间超过了某班次的发车时间,则显示“此班已发出”的提示信息)。
(3)查询路线:可按班次号查询,可按终点站查询(4)售票和退票功能A:当查询出已定票人数小于额定载量且当前系统时间小于发车时间时才能售票,自动更新已售票人数B:退票时,输入退票的班次,当本班车未发出时才能退票,自动更新已售票人数(二)其它要求:(1) 只能使用C/C++语言,源程序要有适当的注释,使程序容易阅读(2) 至少采用文本菜单界面(如果能采用图形菜单界面更好)(3) 学生可自动增加新功能模块******************************************************************* ************************************************/ #include<stdio.h>#include<stdlib.h>#include<dos.h>#include<time.h>#include<conio.h>#include<string.h>const int MAX=20;const int N=50;const int MAXFILENAME=100; enum {FALSE,TRUE};struct time{int hour;int minutes;};struct ticket{int SerialNumber;struct time SetOut;char DeparturePoint[MAX];char TerminalPoint[MAX];float LastTime;int FixNumber;int FixedNumber;}car[N];int RecordNumber;int FLAG=FALSE;/**********************************************/ int ShowMessage(void); //载入原始数据void mainmenu(void); //主菜单void InsertMessage(void); //录入班次信息void SearchMenu(void); //查询路线子菜单void SearchByNumber(void); //按班次号查询void SearchByAddress(void); //按终点站查询void TicketManagement(void); //车票售出与退回void TicketOrder(void); //售票void TicketDelete(void); //退票void exit(void); //退出该系统/********************************************/ int main(void){RecordNumber=ShowMessage();if(1)do{mainmenu();}while(FLAG==FALSE);return 0;}void mainmenu(void){system("color 1f");system("mode con: cols=140 lines=130");char functionNumber;printf(" 车票管理系统\n\n");printf(" 制作:hmm182007\n");printf(" 日期:2007/11/25/19:57\n");printf("=========================================================== =============== ==\n");printf(" 1.录入班次信息\t\n");printf(" 2.浏览班次信息\t\n");printf(" 3.查询行车路线\t\n");printf(" 4.售票与退票系统\t\n");printf(" 5.退出该系统\t\n");printf("=========================================================== =============== ==\n");printf("请选择你所需要的功能:");scanf("%c",&functionNumber);switch(functionNumber){case '1':{InsertMessage();printf("\n按任意键回主菜单......\n"); getchar();getchar();}break;case '2':{ShowMessage();printf("\n按任意键回主菜单......\n"); getchar();getchar();}break;case '3':{SearchMenu();printf("\n按任意键回主菜单......\n"); getchar();getchar();}break;case '4':{TicketManagement();getchar();getchar();}break;case '5':FLAG=TRUE;exit();break;default:{printf("输入错误,请确保你的输入为1--5.\n"); printf("按任意键回主菜单......\n");getchar();getchar();}}//switch endsFLAG=FALSE;}void InsertMessage(void){FILE *fp;char filename[MAXFILENAME];int i;printf("请输入文件名或者文件路径名:");scanf("%s",filename);if((fp=fopen(filename,"r"))==NULL){printf("文件%s不可读,请确认文件%s存在或者文件路径正确.\n\n",filename,filename);mainmenu();}for(i=RecordNumber;!feof(fp)&&!ferror(fp);i++){fscanf(fp,"%d%d%d",&car[i].SerialNumber,&car[i].SetOut.hour,&car[i] .SetOut.minutes);fscanf(fp,"%s%s%f%d%d",&car[i].DeparturePoint,&car[i].TerminalPoint ,&car[i].LastTime,&car[i].FixNumb er,&car[i].FixedNumber);}int count=i;printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n");for(i=0;i<count;i++){printf("%d\t%d:%d\t\t",car[i].SerialNumber,car[i].SetOut.hour,car[i ].SetOut.minutes);printf("%s\t%s\t\t%.1f\t%d\t\t%d\n",car[i].DeparturePoint,car[i].TerminalPoint,car[i].LastTime,c ar[i].FixNu mber,car[i].FixedNumber);}fclose(fp);}int ShowMessage(void){int i;FILE *fp;if((fp=fopen("add.txt","r"))==NULL){printf("读取数据失败,请检查文件add.txt是否存在.\n"); exit(-1);}for(i=0;!feof(fp)&&!ferror(fp);i++){。
#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;}。
java+web+mysql火车票管理系统课程设计
火车票管理系统是一个非常常见的项目,可以用Java语言编写。
以下是一个简单的课程设计框架示例:
1. 系统需求分析
- 确定系统的基本功能需求,如用户登录、车票查询、订单
管理等。
- 确定系统的非功能需求,如界面友好、响应快速等。
2. 数据库设计
- 设计系统所需的数据库表结构,如用户表、车次表、订单
表等。
- 设计表之间的关系,如用户表与订单表的关联关系。
3. 界面设计
- 设计系统的用户界面,包括登录界面、主界面、查询界面、订单管理界面等。
- 界面应该直观、易用,符合用户的操作习惯。
4. 功能开发
- 编写用户登录功能,实现用户的注册、登录、注销等操作。
- 编写车票查询功能,实现按日期、起点站、终点站等条件
进行查询。
- 编写订单管理功能,实现订单的新增、修改、删除等操作。
5. 数据库操作
- 使用Java的JDBC接口操作MySQL数据库。
- 编写数据库访问层,封装数据库操作,提供给其他模块使用。
6. 系统集成测试
- 对各个模块进行集成测试,确保系统的功能正常运行。
- 测试用户登录、车票查询、订单管理等功能。
7. 系统部署与运行
- 部署系统到服务器,确保能够正常运行。
- 测试系统在实际环境下的稳定性和性能。
以上仅为简单的课程设计框架示例,具体的项目实现细节和功能需求需要根据自己的具体情况进行调整和完善。
希望对你的课程设计有帮助!。
#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<string.h>#include "time.h"//班次信息表#define SIZELIMIT 10 //每班次的具体信息的字符个数限制在10以内#define MAXNUM 1000 //设定最多只能录入1000个车次信息typedef struct cardbase //定义一个关于班次信息的结构体,取名为CardBase {char C_ID[SIZELIMIT];//班次char C_TIME[SIZELIMIT];//发车时间char C_ANAME[SIZELIMIT];//起点站char C_BNAME[SIZELIMIT];//终点站char C_USETIME[SIZELIMIT];//行车时间char C_MAXNUM[SIZELIMIT];//额定载量char C_REMAINNUM[SIZELIMIT];//余票数量}CardBase;int cbNum=0;//记录班次数CardBase cBList[MAXNUM];//班次列表//读取班次信息void readcardbasefile()FILE *fp;//打开文件失败则创建文件if((fp=fopen("./number.dat","r"))==NULL){//初次运行创建文件if ((fp=fopen("./number.dat","w"))==NULL){exit(0); //返回}else{fclose(fp);}return ;}/*文件位置指针移动到文件末尾*/fseek(fp,0,2);//重定位文件内部位置指针/* int fseek( FILE *stream, long offset, int origin );第一个参数stream为文件指针第二个参数offset为偏移量,正数表示正向偏移,负数表示负向偏移第三个参数origin设定从文件的哪里开始偏移,可能取值为:SEEK_CUR、 SEEK_END 或SEEK_SETSEEK_SET:文件开头SEEK_CUR:当前位置SEEK_END:文件结尾其中SEEK_SET,SEEK_CUR和SEEK_END依次为0,1和2.简言之:fseek(fp,100L,0);把stream指针移动到离文件开头100字节处;fseek(fp,100L,1);把stream指针移动到离文件当前位置100字节处;fseek(fp,-100L,2);把stream指针退回到离文件结尾100字节处。
引言概述:车票管理系统是一种用于管理车票信息,包括购票、退票、查询票务等功能的软件系统。
本文将以C语言为编程语言,详细阐述如何编写一个车票管理系统。
该系统可以方便管理者对车票信息进行操作,同时也提供给用户便捷的购票和查询功能。
正文内容:一、数据库设计1.1数据库表的建立1.2表中字段的设置1.3数据库的连接与操作1.4数据库的备份与恢复1.5数据库的维护与优化二、用户管理2.1用户注册2.2用户登录2.3用户信息修改2.4用户权限管理2.5用户数据备份与恢复三、车票管理3.1车票添加3.2车票查询3.3车票修改3.4车票删除3.5车票排序和筛选四、订单管理4.1订单4.2订单查询4.3订单修改4.4订单删除4.5订单统计和报表五、支付管理5.1支付方式的选择5.2支付状态的更新5.3支付记录的查询5.4退款管理5.5支付安全性保证总结:通过本文详细的阐述,我们了解到了如何使用C语言编写一个车票管理系统。
在系统的开发过程中,数据库设计、用户管理、车票管理、订单管理和支付管理等方面都需要详细考虑。
通过对每个模块的分析和设计,能够使系统更加高效、安全和易用。
在实际开发中,我们还需要根据具体需求进行对系统的优化和完善,保证系统能够满足用户的需求,并且能够稳定运行。
希望本文对您有所帮助,能够指导您在C语言中编写车票管理系统的开发过程。
引言概述:C语言编写车票管理系统是一个涉及到计算机编程技术的项目,旨在帮助车票销售员和管理员更好地管理和控制车票的销售与出票过程。
本文将详细介绍该系统的设计和实现过程,包括系统的功能需求、系统的结构设计、关键代码的实现以及系统的优化与改进。
正文内容:1.功能需求车票管理系统的功能需求包括但不限于:车票销售、车票查询、座位管理、车票退换等。
具体的系统功能要求涉及到对车票信息的录入、查询、修改和删除,车票的座位分配和座位的查询,以及对车票销售记录的统计和报表等功能。
1.1车票销售功能实现车票销售功能是车票管理系统的核心功能之一。
计算机科学与技术系信息管理与信息系统专业《程序设计综合课程设计》报告(2013/2014学年第一学期)学生姓名:学生班级:学生学号:指导教师:2013年1月8日目录第一章课程设计的目的和要求 (1)1.1课程设计的目的 (1)1.2 课程设计的基本要求 (1)第二章课程设计任务内容 (2)2.1 简介 (2)2.2 功能说明 (2)第三章详细设计说明 (3)3.1 模板设计图 (3)3.2 主函数流程图 (4)3.3 子函数流程图 (5)第四章编码与调试 (7)4.1 软件使用说明 (7)4.2 运行结果及截图 (7)第五章课程设计心得与体会 (11)附录一参考文献 (12)附录二程序清单 (13)附录三录入文件 (27)火车票管理系统第一章课程设计的目的和要求高级语言课程设计的主要目的是培养学生能够提高综合应用语言的能力,通过课程设计的训练,使学生能及时巩固已学的知识,补充未学的但有必要的内容,掌握应用计算机解决实际问题的基本方法,熟悉程序开发的全过程,提高综合应用语言的能力。
高级语言程序设计的主要任务是要求学生遵循软件开发过程的基本规范,运用结构程序设计的方法按照课程设计的题目要求,分析,编写,调试和测试高级语言程序及编写设计报告。
1.1课程设计的目的1.巩固和掌握高级语言程序设计基本概念;2.掌握基本的程序设计方法;3.掌握开发软件所需的需求定义能力;4.提高书写程序设计说明文档的能力;5.提高综合运用高级语言的能力,强化编程和调试能力。
1.2 课程设计的基本要求1.根据所给的课程设计题目,分析课程设计题目的要求;2.对系统功能模块进行分析,写出详细的设计说明文档;3.编写程序代码,调试所编写程序使其能正确运行;4.设计完成的软件便于操作和使用;5.设计完成后提交课程设计报告。
第二章课程设计任务内容2.1 简介火车票管理系统:是为广大群众开发的,帮助人们查询车次信息,订票和退票,大大节约了人们的时间,是铁路营运公司所需要的全部功能的一个综合的管理系统。
火车票务管理系统一、课题内容和要求设计目标:设计一个火车票务管理系统,用C语言实现。
对该系统的要求如下:需求描述:1.系统功能(1)火车时刻信息录入。
包括车次、日期、起点、终点、开车时间、到达时间、票价。
数据存入数据文件hchsk.dat或hchsk.txt中。
(2)火车时刻信息查询。
按照车次查询按终点查询按起点查询按终点和日期查询(3)统计按终点统计每日的车次数按起点统计每日的车次数2. 系统主界面应有以下功能选项录入火车时刻信息查询火车时刻信息统计火车车次退出注:建议用VC环境开发用户界面。
结果形式:提交程序设计报告和可演示的系统软件二、需求分析系统主界面应有以下功能选项1.录入火车时刻信息2.查询火车时刻信息3.统计火车车次4.退出(1)火车时刻信息录入。
包括车次、日期、起点、终点、开车时间、到达时间、票价。
数据存入数据文件hchsk.dat或hchsk.txt中。
(2)火车时刻信息查询。
按照车次查询按终点查询按起点查询按终点和日期查询(3)统计按终点统计每日的车次数按起点统计每日的车次数二、概要设计void SearchTrainNum();//按照车次查询void SearchToPlace();//按终点查询void SearchFromPlace();//按起点查询void SearchToPlaceAndDate();//按终点和日期查询void CountToPlace();//按终点统计每日的车次数void CountFromPlace();//按起点统计每日的车次数三、详细设计程序的源代码与注释#include<stdio.h>#include<string.h>#include<stdlib.h>void SearchTrainNum();void SearchToPlace();void SearchFromPlace();void SearchToPlaceAndDate();void CountToPlace();void CountFromPlace();void Star();struct TRAIN{char trainNum[10];char date[30];char fromPlace[20];char toPlace[20];char inTime[30];char outTime[30];double price;};struct TRAIN train[30];int main(){int request;char ch='Y';int i=0;double myprice;FILE *fp;repeat:Star();printf("火车管理系统界面\n");printf("1.录入火车时刻信息.\n");printf("2.查询火车时刻信息.\n");printf("3.统计火车车次.\n");printf("4.退出.\n");Star();printf("\n");printf("请输入:");scanf("%d",&request);switch(request) //利用case分支结构{case 1:{ fp=fopen(".\\train.rec","wb"); //利用文件与流if(!fp){printf("File can not be opened\n");exit(1);}do{printf("Enter车次日期起点终点开车时间到达时间票价\n>>> ");scanf("%s%s%s%s%s%s%lf",train[i].trainNum,train[i].date,train[i].fromPlace ,train[i].toPlace,train[i].inTime,train[i].outTime,&myprice);train[i].price=myprice;fwrite(&train[i],sizeof(struct TRAIN),1,fp);i++;printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');fclose(fp);printf("返回主界面吗?(Y返回)");getchar();scanf("%c",&ch);if(ch=='Y'){printf("\n\n");goto repeat;}}break;case 2:{ printf("\n\n");printf(">>>>>火车时刻信息查询<<<<<\n");printf("1.按车次查询.\n");printf("2.按终点查询.\n");printf("3.按起点查询.\n");printf("4.按终点和日期查询.\n");printf("5.退出.\n");printf("请输入:");scanf("%d",&request);switch(request){case 1: SearchTrainNum(); break; case 2: SearchToPlace(); break;case 3: SearchFromPlace(); break; case 4: SearchToPlaceAndDate(); break; case 5: exit(0); break;}printf("返回主界面吗?(Y返回)");getchar();scanf("%c",&ch);if(ch=='Y'){printf("\n\n");goto repeat;}} break;case 3:{printf("\n\n");printf(">>>>>火车车次统计系统<<<<<\n");printf("1.按终点统计每日的车次数.\n");printf("2.按起点统计每日的车次数.\n");printf("3.退出.\n");printf("请输入:");scanf("%d",&request);switch(request){case 1: CountToPlace(); break;case 2: CountFromPlace(); break;case 3: exit(0); break;}printf("返回主界面吗?(Y返回)");getchar();scanf("%c",&ch);if(ch=='Y'){printf("\n\n");goto repeat;}} break;case 4:{Star();printf("欢迎下次使用,拜拜~~\n"); Star();}exit(0); break;default:printf("Incorrect num entered.");printf("Enter a new num.\n");break;}return 0;}void SearchTrainNum(){FILE *fp1;char num[20];char ch;int i=0;fp1=fopen(".\\train.rec","r+");if(!fp1){printf("File can not be opened\n");exit(1);}do{rewind(fp1); //文件指针的操作,到文件头部函数printf("输入你要查找的车次号.\n>>>");scanf("%s",num);while(!feof(fp1)){fread(&train[i],sizeof(struct TRAIN),1,fp1);if(strcmp(num,train[i].trainNum)==0){printf("%-4s%-12s%-8s%-10s%-10s%-8s%.2lf",train[i].trainNum,train[i].date, train[i].fromPlace,train[i].toPlace,train[i].inTime,train[i].outTime,train[i].price);printf("\n");}i++;}printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');printf("\n");fclose(fp1);}void SearchToPlace(){FILE *fp2;char num[20];char ch;int i=0;fp2=fopen(".\\train.rec","r+");if(!fp2){printf("File can not be opened\n");exit(1);}do{rewind(fp2);printf("输入你要查询的终点.\n>>>");scanf("%s",num);while(!feof(fp2)){fread(&train[i],sizeof(struct TRAIN),1,fp2);if(strcmp(num,train[i].toPlace)==0){printf("%-4s%-12s%-8s%-10s%-10s%-8s%.2lf",train[i].trainNum,train[i].date, train[i].fromPlace,train[i].toPlace,train[i].inTime,train[i].outTime,train[i].price);printf("\n");}i++;}printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');printf("\n");fclose(fp2);}void SearchFromPlace(){FILE *fp3;char num[20];char ch;int i=0;fp3=fopen(".\\train.rec","r+");if(!fp3){printf("File can not be opened\n");exit(1);}do{rewind(fp3);printf("输入你要查询的起点.\n>>>");scanf("%s",num);while(!feof(fp3)){fread(&train[i],sizeof(struct TRAIN),1,fp3);if(strcmp(num,train[i].fromPlace)==0){printf("%-4s%-12s%-8s%-10s%-10s%-8s%.2lf",train[i].trainNum,train[i].date,tra in[i].fromPlace,train[i].toPlace,train[i].inTime,train[i].outTime,train[i].price);printf("\n");}i++;}printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');printf("\n");fclose(fp3);}void SearchToPlaceAndDate(){FILE *fp4;char num[20];char num1[20];char ch;int i=0;fp4=fopen(".\\train.rec","r+");if(!fp4){printf("File can not be opened\n");exit(1);}do{rewind(fp4);printf("输入你要查询的终点与日期.\n>>>");scanf("%s",num);scanf("%s",num1);while(!feof(fp4)){fread(&train[i],sizeof(struct TRAIN),1,fp4);if((strcmp(num,train[i].toPlace)==0)&&(strcmp(num1,train[i].date)==0)) {printf("%-4s%-12s%-8s%-10s%-10s%-8s%.2lf",train[i].trainNum,train[i].date, train[i].fromPlace,train[i].toPlace,train[i].inTime,train[i].outTime,train[i].price); printf("\n");}i++;}printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');printf("\n");fclose(fp4);}void CountToPlace(){FILE *fp5;char num[20];char ch;int i=0;int j=0;fp5=fopen(".\\train.rec","r+");if(!fp5){printf("File can not be opened\n");exit(1);}do{rewind(fp5);printf("输入你(要统计的车次数的)终点.\n>>>");scanf("%s",num);j=0;while(!feof(fp5)){fread(&train[i],sizeof(struct TRAIN),1,fp5);if(strcmp(num,train[i].toPlace)==0){j++;}i++;}printf("当日终点%s的车次数:%d",num,j);printf("\n");printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');fclose(fp5);}void CountFromPlace(){FILE *fp6;char num[20];char ch;int i=0;int j=0;fp6=fopen(".\\train.rec","r+");if(!fp6){printf("File can not be opened\n");exit(1);}do{rewind(fp6);printf("输入你(要统计的车次数的)起点.\n>>>");scanf("%s",num);j=0;while(!feof(fp6)){fread(&train[i],sizeof(struct TRAIN),1,fp6);if(strcmp(num,train[i].fromPlace)==0){j++;}i++;}printf("当日起点%s的车次数:%d",num,j);printf("\n");printf("continue(Y/N)(N to end)?");getchar();scanf("%c",&ch);}while(ch!='N');fclose(fp6);}void Star(){int i;for(i=0;i<20;i++){printf("*");}printf("\n");}四、测试数据及其结果分析(如图)1.火车时刻信息录入2.火车时刻信息查询。