文章插图
【C语言火车订单管理源码】#include #include #include #include #include /*公众号:C语言与CPP编程回复“源码” , 获取30个源码项目*/#define HEADER1 " -------------------------------BOOK TICKET----------------------------------\n"#define HEADER2 " |number|start city|reach city|takeofftime|receivetime|price|ticketnumber|\n"#define HEADER3 " |----------|----------|----------|-----------|-----------|-----|------------|\n"#define FORMAT" |%-10s|%-10s|%-10s|%-10s |%-10s |%5d|%5d|\n"#define DATA p->data.num,p->data.startcity,p->data.reachcity,p->data.takeofftime,p->data.receivetime,p->data.price,p->data.ticketnumint saveflag=0 ;/*定义存储火车信息的结构体*/struct train {char num[10];/*列车号*/char startcity[10];/*出发城市*/char reachcity[10];/*目的城市*/char takeofftime[10];/*发车时间*/char receivetime[10];/*到达时间*/intprice;/*票价*/intticketnum ;/*票数*/};/*订票人的信息*/struct man {char num[10];/*ID*/char name[10];/*姓名*/intbookNum ;/*订的票数*/};/*定义火车信息链表的结点结构*/typedef struct node {struct train data ;struct node * next ;}Node,*Link ;/*定义订票人链表的结点结构*/typedef struct Man {struct man data ;struct Man *next ;}book,*bookLink ;/* 初始界面*/void menu(){puts("\n\n");puts("\t\t|------------------------------------------------------|");puts("\t\t|Booking Tickets|");puts("\t\t|------------------------------------------------------|");puts("\t\t|0:quit the system|");puts("\t\t|1:Insert a train information|");puts("\t\t|2:Search a train information|");puts("\t\t|3:Book a train ticket|");puts("\t\t|4:Modify the train information|");puts("\t\t|5:Show the train information|");puts("\t\t|6:save information to file|");puts("\t\t|------------------------------------------------------|");}/*添加一个火车信息*/void Traininfo(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'is existing!\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 start:");scanf("%s",p->data.startcity);/*输入出发城市*/printf("Input the city where the train will reach:");scanf("%s",p->data.reachcity);/*输入到站城市*/printf("Input the time which the train take off:"); scanf("%s",p->data.takeofftime);/*输入出发时间*/printf("Input the time which the train receive:"); scanf("%s",/*输入到站时间*/printf("Input the price of ticket:");scanf("%d",/*输入火车票价*/printf("Input the number of booked tickets:"); scanf("%d",/*输入预定票数*/p->next=NULL ;r->next=p ;/*插入到链表中*/r=p ;saveflag = 1 ;}}/*打印火车票信息*/void printheader() /*格式化输出表头*/{printf(HEADER1);printf(HEADER2);printf(HEADER3);}void printdata(Node *q) /*格式化输出表中数据*/{Node* p;p=q;printf(FORMAT,DATA);}/*查询火车信息*/void searchtrain(Link l){Node *s[10],*r;int sel,k,i=0 ;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",/*输入选择的序号*/if(sel==1){printf("Input the the number of train:");scanf("%s",str1);r=l->next; while(r!=NULL)if(strcmp(r->data.num,str1)==0)/*检索是否有与输入的车号相匹配的*/{s[i]=r;i++;break;}elser=r->next;}else if(sel==2){printf("Input the cityyou want to go:");scanf("%s",str2);r=l->next; while(r!=NULL)if(strcmp(r->data.reachcity,str2)==0)/*检索是否有与输入的城市相匹配的火车*/{s[i]=r;i++;r=r->next;}elser=r->next;}if(i==0)printf("can not find!"); else {printheader();for(k=0;k
推荐阅读
-
大嘴扒|鹿晗最新视频截图,被质疑脸垮了,网友:年纪大了
-
「地震」山西祁县发生3.7级地震,网友:太原有震感
-
-
-
男爵电竞|和平精英:主播和职业选手差距在哪?虎牙巅峰赛46人一决高下!
-
-
张馨予没火时的旧照流出:这扑面而来的风尘味儿,隔屏幕上头
-
时尚丽人风行|44岁靳东帅到炸裂!穿中山装梦回“明楼”,梳大背头化身霸道总裁
-
-
佘诗曼|44岁佘诗曼麻花辫录节目,杏色T配百褶裙很少女,美得像小姑娘
-
-
西游记|袁守诚为何敢泄漏玉帝旨意,害死泾河龙王?你看他师父和侄子是谁
-
高叶|高叶的身材,徐璐的颜值,《你安全吗?》的爆款密码这次藏不住了
-
智通财经|半导体板块遭沽售 中芯国际净流出超9亿,北水动向(8.5)|北水净流入9.39亿
-
QQ炫舞手游|音乐华服&钻石送送送!夏日音乐节就要一起“浪”翻天
-
[塔罗师傅宇]真情彷徨,跟前任重新牵手,愿再次相聚,双鱼座:五月初一
-
英超|举世罕见!英超劲旅因误判降级:1亿收入没了 要求赔偿损失
-
-
陈生浅谈古今|他到底有多聪明?,张岱为什么被称作明代才子
-
政商参阅马斯克为什么这么厉害?底层有一套强大的思维方式!