train订票系统优化最终版

2024-06-15 20:32

本文主要是介绍train订票系统优化最终版,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

.h文件#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>struct train {//车次的属性int id;char name[50];int remainTickets;
};struct node {//普通节点的属性struct node *next;struct train * train_inform;	
};struct head {//头节点属性struct node * nd;int fg;
};struct list{//链表的属性struct head * listhead;int len;
};struct list * initList();struct list * createList(struct list * l);struct node * searchTrain(struct list * l,int id);int printNode(struct node * train);int printList(struct list * l);int bookTrain(struct list * l,int id);int returnTrain(struct list * l,int id);struct list * addTainInform(struct list * l);struct list * deleteTainInform(struct list * l,int id);struct list * createAllTrainInform();int login();int userUsage(struct list * l);int administratorUsage(struct list * l);int userMenu(struct list * l);int administratorMenu(struct list * l);.c文件#include "train优化.h"int main()
{login();return 0;
}struct list * initList(){struct list * l;l = (struct list *)malloc(sizeof(struct list));l->listhead = (struct head *)malloc(sizeof(struct head));l->listhead->nd = (struct node *)malloc(sizeof(struct node));l->listhead->nd->train_inform = (struct train *)malloc(sizeof(struct train));l->listhead->nd->next=NULL;l->len=0;return l;
}struct list * createList(struct list * l){int id;char name[50];int remainTickets;struct node * p, * last;last=l->listhead->nd;printf("依次输入:列车id号,名称,剩余票数(id==-1终止!)\n");scanf("%d%s%d",&id,&name,&remainTickets);while(id!=-1){p=(struct node *)malloc(sizeof(struct node));p->train_inform=(struct train *)malloc(sizeof(struct train));p->train_inform->id=id;strcpy(p->train_inform->name,name);p->train_inform->remainTickets=remainTickets;l->len++;last->next=p;  last=p;  p->next=NULL;scanf("%d%s%d",&id,&name,&remainTickets);}return l;
}struct node * searchTrain(struct list * l,int id){//查询,返回节点信息struct node * p;p = l->listhead->nd;while(p!=NULL){if(p->train_inform->id==id){break;}p=p->next;}return p;
}int printNode(struct node * train){//打印节点信息if(train!=NULL){printf("列车id: %d\n",train->train_inform->id);printf("列车名称:%s\n",train->train_inform->name);printf("剩余票数:%d\n",train->train_inform->remainTickets);}else{printf("系统内无此列车信息!\n");}return 0;
}int printList(struct list * l){struct node * p;p = l->listhead->nd->next;while(p!=NULL){printNode(p);p=p->next;}return 0;
}int bookTrain(struct list * l,int id){//订票struct node * p;p = l->listhead->nd;while(p!=NULL){if(p->train_inform->id==id){p->train_inform->remainTickets--;break;}p=p->next;}printNode(p);return 0;
}int returnTrain(struct list * l,int id){//退票struct node * p;p = l->listhead->nd;while(p!=NULL){if(p->train_inform->id==id){p->train_inform->remainTickets++;break;}p=p->next;}printNode(p);return 0;
}struct list * addTainInform(struct list * l){int id;char name[50];int remainTickets;struct node * p, * last , * check;last = l->listhead->nd;while(last->next!=NULL){last=last->next;}printf("依次输入:列车id号,名称,剩余票数!\n");scanf("%d%s%d",&id,&name,&remainTickets);check = l->listhead->nd;while(check!=last){check=check->next;if(id==check->train_inform->id||strcmp(name,check->train_inform->name)==0){printf("添加失败!id号或列车名称重复!\n");return l;}}p=(struct node *)malloc(sizeof(struct node));p->train_inform=(struct train *)malloc(sizeof(struct train));p->train_inform->id=id;strcpy(p->train_inform->name,name);p->train_inform->remainTickets=remainTickets;l->len++;last->next=p;  last=p;  p->next=NULL;printf("%s列车信息已添加!\n",p->train_inform->name);return l;
}struct list * deleteTainInform(struct list * l,int id){struct node * p;p = l->listhead->nd;while(p!=NULL){if(p->train_inform->id==id){break;}p=p->next;}if(l->listhead->nd->next==NULL){printf("列车信息为空!删除失败!\n");}else{p = l->listhead->nd->next;l->listhead->nd->next=p->next;printf("%s列车信息被删除!\n",p->train_inform->name);free(p);}return l;
}struct list * createAllTrainInform(){struct list * l;l=initList();printf("请输入列车原始信息!\n");l = createList(l);return l;
}int login(){int x;struct list * l;l = createAllTrainInform();printf("请登录!\n1.管理员登录 2.用户登录\n");scanf("%d",&x);switch(x){case 1:administratorUsage(l);break;case 2:userUsage(l);break;default:return 0;}return 0;
}int userUsage(struct list * l){//打印用户提示界面printf("请按提示输入完成操作!\n");printf("1.查询车次信息\n");printf("2.订票\n");printf("3.退票\n");printf("4.退出系统\n");userMenu(l);return 0;
}int administratorUsage(struct list * l){//打印管理员提示界面int pass;
loop:	printf("请输入管理员密码:");scanf("%d",&pass);if(pass==123456){printf("请按提示输入完成操作!\n");printf("1.查询车次信息\n");printf("2.增加车次信息\n");printf("3.删除车次信息\n");printf("4.打印所有车次信息\n");printf("5.退出系统\n");administratorMenu(l);}else{printf("密码错误!请重新输入!\n");goto loop;}return 0;
}int userMenu(struct list * l){int x,id;int k=1;struct node * p;while(k){printf("请输入序列号:");scanf("%d",&x);switch(x){case 1:printf("输入所要查询的列车的id号:");scanf("%d",&id);p = searchTrain(l,id);if(p==NULL){printf("//\n");break;}printNode(p);printf("//\n");break;case 2:printf("输入所要订票的列车的id号:");scanf("%d",&id);bookTrain(l,id);printf("//\n");break;case 3:printf("输入所要订票的列车的id号:");scanf("%d",&id);bookTrain(l,id);printf("//\n");break;case 4:k=0;printf("已退出系统……\n");printf("//\n");break;default:return 0;}}return 0;
}int administratorMenu(struct list * l){int x,id;int k=1;struct node * p;while(k){printf("请输入序列号:");scanf("%d",&x);switch(x){case 1:printf("输入所要查询的列车的id号:");scanf("%d",&id);p = searchTrain(l,id);printNode(p);printf("//\n");break;case 2:printf("添加列车信息!\n");l=addTainInform(l);printf("//\n");break;case 3:printf("输入所要删除的列车的id号:");scanf("%d",&id);l=deleteTainInform(l,id);printf("//\n");break;case 4:printList(l);printf("//\n");break;case 5:k=0;printf("已退出系统……\n");printf("//\n");break;default:return 0;}}return 0;
}

这篇关于train订票系统优化最终版的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1064498

相关文章

【chatgpt】train_split_test的random_state

在使用train_test_split函数划分数据集时,random_state参数用于控制随机数生成器的种子,以确保划分结果的可重复性。这样,无论你运行多少次代码,只要使用相同的random_state值,得到的训练集和测试集划分就会是一样的。 使用 train_test_split 示例 以下是一个示例,展示如何使用train_test_split函数进行数据集划分,并设置random_s

java实训 | 低配版模拟火车订票系统

代码:  import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.util.ArrayList;import java.util.List;public class TrainBookingSystem {private JFrame frame;private JPanel

linux面试题(系统管理类——系统优化)

如何进行linux系统优化 禁用不需要的服务(ntsysv命令最为方便)避免直接使用root用户,普通用户通过sudo授权操作通过chattr锁定重要系统文件(/etc/passed,/etc/shadow/etc/group,/etc/gshadow,/etc/inittab)配置国内源,加快下载速度配置系统同时打开最大文件数(vi /etc/profile,ulimit -SHn 65535

tf.train.batch和tf.train.shuffle_batch的理解

capacity是队列的长度 min_after_dequeue是出队后,队列至少剩下min_after_dequeue个数据 假设现在有个test.tfrecord文件,里面按从小到大顺序存放整数0~100 1. tf.train.batch是按顺序读取数据,队列中的数据始终是一个有序的队列, 比如队列的capacity=20,开始队列内容为0,1,..,19=>读取10条记录后,队列剩下10,

基于springboot实现影院订票系统项目【项目源码+论文说明】计算机毕业设计

基于springboot实现影院订票系统演示 摘要 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本影院订票系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此影院订票系统利用当下成熟完善的SSM框架,使用跨平台的可

文章解读与仿真程序复现思路——电力系统自动化EI\CSCD\北大核心《基于IGDT-效用熵的园区综合能源系统优化配置方法》

本专栏栏目提供文章与程序复现思路,具体已有的论文与论文源程序可翻阅本博主免费的专栏栏目《论文与完整程序》 论文与完整源程序_电网论文源程序的博客-CSDN博客https://blog.csdn.net/liang674027206/category_12531414.html 电网论文源程序-CSDN博客电网论文源程序擅长文章解读,论文与完整源程序,等方面的知识,电网论文源程序关注python

ValueError: Shape must be rank 0 but is rank 1 for 'train_data/ReadFile' (op: 'ReadFile') with input

使用函数tf.train.slice_input_producer读取文件时, input_queue = tf.train.slice_input_producer([flist], shuffle=self.shuffle,seed=0123, num_epochs=self.num_epochs)input_file = tf.read_file(input_queue) 出现错误:

寻路最终版哦

转自:http://blog.csdn.net/yxriyin/article/details/40902063 相信大家用Unity3D自带navmeshagent寻路的时候,一定会碰到多人寻路相互挤压的问题。 这个我已经解决了,而且已经应用到我们的项目中,感觉还不错。 首先提下问题的原因:navmeshagent在寻路的时候,并不会把别人当成障碍物,而是在即将和其他agent碰撞的时候,

火车票订票系统(简化版)

#include "train简化.h"int main(){usage();return 0;}#include <stdio.h>#include <stdlib.h>#include <string.h>struct train{int id;char name[50];int remainTickets;struct train * next;};struct train * a

caffe CNN train_val.prototxt 神经网络参数配置说明

name: "CaffeNet"layer {#输入层,即数据层#数据层的类型除了Database外,还可以是In-Memory、HDF5 Input、HDF5 Output、Images、Windows、Dummyname: "data"type: "Data"top: "data"top: "label"include {phase: TRAIN#表示仅在训练阶段包括进去