停车场管理系统程序设计c语言数据结构,数据结构(C语言)—停车场管理系统...
2014-01-02 回答
#include
#include
#include
#include
#define max 3
#define price 1
int b=1;
typedef struct
{
int day;
int hour;
int min;
}TIME;//时间结点
typedef struct
{
char num[10]; //车牌号
TIME time; //进入停车场的时间
int n; //进入停车场的位置
}information;
//栈结构体定义
typedef struct node
{
information data;
struct node *next;
}stacknode;stacknode *top1,*top2;
//队列结构体定义
typedef struct
{
information data;
stacknode *front,*rear;
}LQueue;LQueue *Q;
//函数声明部分/
stacknode *Init(); //栈的初始化
stacknode *into(stacknode *top1,LQueue *Q); //初始化车辆进入
int expenses(stacknode *p,int x,int y); //停车费用计算函数
stacknode *leave(stacknode *top1,char str[],LQueue *Q); //车辆驶出出场函数
LQueue *InitLQue(); //初始化队列函数
LQueue *wait(LQueue *q,stacknode *s); //车辆进入候车便道函数
int EmptyLQue(LQueue *q); //判断候车便道有无等待车辆函数
stacknode *out(LQueue *q); //候车区车辆出队
stacknode *LQinto(stacknode *p,stacknode *top1); //从候车便道进入停车场函数
void show(stacknode *top1); //显示停车场所有信息函数
void T_shou(LQueue *Q); //显示候车区信息
/*函数部分*/
//主函数
void main()
{
char str[10];
Q=InitLQue();
top1=Init();
top2=Init();
Q=InitLQue();
int i;
printf("\t\t\t*************************************\n");
printf("\t\t\t\t 停车场管理系统\n");
printf("\t\t\t|| 1. 车辆进入停车场 ||\n");
printf("\t\t\t|| 2. 车辆离开停车场 ||\n");
printf("\t\t\t|| 3. 显示停车场内所有车辆信息 ||\n");
printf("\t\t\t|| 4. 显示候车区内所有车辆信息 ||\n");
printf("\t\t\t|| 5. 退出 ||\n");
printf("\t\t\t*************************************\n");
while(i!=5)
{
printf("\t请输入选项1-5:");
scanf("%d",&i);
switch(i)
{
case 1:
top1=into(top1,Q);
break;
case 2:
printf("请输入离开车辆的车牌号:");
scanf("%s",str);
top1=leave(top1,str,Q);
break;
case 3:show(top1);break;
case 4:T_shou(Q);break;
case 5:exit(1);
default:printf("输入错误,请重新输入1—5:");
break;
}
}
}
/*子函数*/
//初始化
stacknode *Init()
{
stacknode *top;
top=(stacknode *)malloc(sizeof(stacknode));
top=NULL;
return top;
}
//初始化车辆进入
stacknode *into(stacknode *top1,LQueue *Q)
{
stacknode *p,*q;
time_t rawtime; //调用系统时间函数
struct tm *timeinfo; //时间结点
time(&rawtime);
timeinfo=localtime(&rawtime);
p=(stacknode *)malloc(sizeof(stacknode));
if(p==NULL)
{
printf("内存分配失败");
return top1;
}
printf("请输入进入停车场车辆的车牌号:");
scanf("%s",p->data.num);
q=top1;
while(q!=NULL)
{
if(strcmp(p->data.num,q->data.num)==0)
{
printf("车牌号输入有误,该车已进入!");
return top1;
}
q=q->next;
}
p->data.time.day=timeinfo->tm_mday;
p->data.time.hour=timeinfo->tm_hour;
p->data.time.min=timeinfo->tm_min;
p->data.n=b;
if(b>max)
{
printf("停车场已满,请在便道等候!\n");
wait(Q,p);
return top1;
}
if(top1==NULL)
{
p->next=NULL;
top1=p;
}
else
{
p->next=top1;
top1=p;
}
b++;
printf("车辆进入停车场成功,时间已经自动载入!\n");
printf("车牌为%s的汽车驶入时间为:%d号%d点%d分\n",top1->data.num,top1->data.time.day,top1->data.time.hour,top1->data.time.min);
return top1;
}
//停车费用计算函数
int expenses(stacknode *p,int x1,int x2,int x3)
{
int w;
if(x3!=0)
w=(x1*24+x2+1-(p->data.time.day*24+p->data.time.hour))*price;
else
w=(x1*24+x2-(p->data.time.day*24+p->data.time.hour))*price;
return w;
}
//车辆驶出出场函数
stacknode *leave(stacknode *top1,char str[],LQueue *Q)
{
int i,day,hour,min;
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo=localtime(&rawtime);
day=timeinfo->tm_mday;
hour=timeinfo->tm_hour;
min=timeinfo->tm_min;
stacknode *p,*q;
if(top1==NULL)
{
printf("停车场没有车辆!\n");
return top1;
}
q=(stacknode *)malloc(sizeof(stacknode));
if(p==NULL)
{
printf("内存分配失败");
return top1;
}
q=top1;
while(q!=NULL)
{
if(strcmp(q->data.num,str)==0)
break;
q=q->next;
}
if(q==NULL)
{
printf("输入有误,该车辆不在停车场!\n");
return top1;
}
for(i=top1->data.n;i>q->data.n;i--)
{
p=(stacknode *)malloc(sizeof(stacknode));
if(p==NULL)
{
printf("内存分配失败");
return top1;
}
strcpy(p->data.num,top1->data.num);
p->data.time=top1->data.time;
p->data.n=top1->data.n-1;
top1=top1->next;
if(top2==NULL)
{
p->next=NULL;
top2=p;
}
else
{
p->next=top2;
top2=p;
}
}
top1=top1->next;
while(top2!=NULL)
{
p=(stacknode *)malloc(sizeof(stacknode));if(p==NULL){printf("内存分配失败");return top1;}
p->data.n=top2->data.n;
strcpy(p->data.num,top2->data.num);
p->data.time=top2->data.time;
p->next=top1;
top1=p;
top2=top2->next;
}
if(EmptyLQue(Q))
{
p=out(Q);
p->data.n--;
top1=LQinto(p,top1);
}
else
b--;
printf("车牌为%s的汽车驶出时间为:%d号%d点%d分\n",q->data.num,day,hour,min);
printf("车辆驶出停车场需要缴纳的费用为:%d元\n",expenses(q,day,hour,min));
return top1;
}
//队列函数初始化
LQueue *InitLQue()
{
LQueue *Q;
stacknode *p;
Q=(LQueue *)malloc(sizeof(LQueue));
p=(stacknode *)malloc(sizeof(stacknode));
p->next=NULL;
Q->front=Q->rear=p;
return Q;
}
//候车区队列入队
LQueue *wait(LQueue *q,stacknode *s)
{
s->next=NULL;
q->rear->next=s;
q->rear=s;
return q;
}
//判断候车便道有无车辆等待
int EmptyLQue(LQueue *q)
{
if(q->front==q->rear)
return 0;
else
return 1;
}
//候车区车辆出队
stacknode *out(LQueue *q)
{
stacknode *p;
p=q->front->next;
if(q->front->next==q->rear)
{
q->rear=q->front;
return p;
}
else
q->front->next=p->next;
p->next=NULL;
return p;
}
//候车队列进入停车场
stacknode *LQinto(stacknode *p,stacknode *top1)
{
p->next=top1;
top1=p;
return top1;
}
//显示停车场内所有车辆信息
void show(stacknode *top1)
{
printf(" 停车场内全部车辆信息表\n");
if(top1==NULL)
printf(" 停车场内无车!\n");
else
{
printf("车牌号 进入时间 位置\n");
while(top1!=NULL)
{
printf(" %s %d号%d点%d分 第%d位\n",top1->data.num,top1->data.time.day,top1->data.time.hour,top1->data.time.min,top1->data.n);
top1=top1->next;
}
}
}
//显示候车区的汽车信息
void T_shou(LQueue *Q)
{
LQueue *q;
q=(LQueue *)malloc(sizeof(LQueue));
q->rear=Q->rear->next;
printf(" 候车区信息\n");
if(q->front==q->rear)
printf("候车区没有车辆!\n");
else
{
printf("车牌号 进入时间\n");
while(q!=NULL)
{
printf("%s%d号%d点%d分",q->data.num,q->data.time.day,q->data.time.hour,q->data.time.min);
q->rear=q->rear->next;
}
}
}
/*时间函数
int timef()
{
int x,y;
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo=localtime(&rawtime);
x=timeinfo->tm_mday,y=timeinfo->tm_hour;
}
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo=locoltime(&rawtime);
timeinfo->tm_ymday,*/
停车场管理系统程序设计c语言数据结构,数据结构(C语言)—停车场管理系统...相关推荐
- 基于C语言的数据结构课程设计(学生管理系统、停车场管理、家谱管理、校园导航系统)
一.设计目的 本课程设计是软件工程学生的必修课程,数据结构与算法课程设计既是一门基础课程,又是一门实践性课程.通过本实训课程的学习和训练,使同学学会分析研究数据对象的特性,学会数据的组织方法,以便选择 ...
- c语言数据结构课程设计停车场管理系统,数据结构课程设计报告停车场管理系统...
<数据结构课程设计报告停车场管理系统>由会员分享,可在线阅读,更多相关<数据结构课程设计报告停车场管理系统(8页珍藏版)>请在人人文库网上搜索. 1.数据结构课程设计报告系 别 ...
- 数据结构大作业之停车场管理系统
数据结构大作业之停车场管理系统 安排: 1. 分析停车场的数据属性,并依据停车场管理的功能要求,确定模拟系统设计方案: 2. 完成停车场管理的数据结构设计工作,包括栈和队列的逻辑结构和存储结构等: 3 ...
- java数据结构停车场管理系统_《数据结构》实验设计报告-停车场管理系统
<<数据结构>实验设计报告-停车场管理系统>由会员分享,可在线阅读,更多相关<<数据结构>实验设计报告-停车场管理系统(28页珍藏版)>请在人人文库网上 ...
- 基于数据结构和C语言实现公交管理系统(含文档和代码)数据结构课程设计
目录 第1章 课程设计内容及要求 第2章 需求分析 第3章 算法设计 3.1 设计思想 3.2 设计表示 第4章 系统调试及测试(含代码) 4.1 功能截图 4.2 实现代码 第5章 课程设计心得 5 ...
- 【1】C++语法与数据结构之C语言学生管理系统转C++学生管理系统
从本文开始,后续将陆续发布C++语法与数据结构的相关内容,同样还是以学生管理系统来融汇贯通所有知识点. 接上篇博客[终极完美高效]C语言实用算法系列之学生管理系统_单向链表外排序_堆内数组存储链表节点 ...
- 结合方式c语言,程序设计C语言与数据结构相结合的教学模式探索
根据学生差异性现状和情景环境下的任务驱动教学模式的有效性,选择和设计合适的项目案例:加强课程联系,整理课程关系.优化课程例题.习题等安排,解决学生作业量大,效率低的现状.通过对两门核心基础课程的探索, ...
- 数据结构(C语言)课设1——单位员工通讯录管理系统(线性表应用)
数据结构(C语言)课设1--单位员工通讯录管理系统(线性表应用) 题目要求: 为某个单位建立一个员工通讯录管理系统,可以方便查询每一个员工的手机号.及电子邮箱.其功能包括通讯录链表的建立.员工通讯信息 ...
- 停车场自动计费系统 c语言,数据结构用c语言实现停车场管理完整系统.doc
数据结构用c语言实现停车场管理完整系统 题目:用C语言实现停车场管理程序的设计 天津农学院 11计算机系计科 小组成员: 王亚洲 1108014219 王浩轩 1108014208 穆建良110801 ...
最新文章
- 【Gans入门】Pytorch实现Gans代码详解【70+代码】
- 机器学习算法实现解析:libFM之libFM的训练过程之SGD的方法
- Codeforces 164 E Compatible Numbers
- 条件随机场 python_用条件随机场做网络小说命名实体识别
- Spring Cloud Nacos
- Altium AD20原理图元件自动编号,位号重新排序
- FPGA实现VGA显示(一)——————屏幕驱动及color_bar显示
- L73.linux命令每日一练 -- 第十章 Linux网络管理命令 -- dig和host
- 【Cocos 3d】粒子特效的制作与使用
- ExtJS实战教程~~前言
- mfc对话框ok没效果_利用PS制作逼真双重曝光效果案例演示,合成紫色城市建筑风格海报图片...
- 火水未濟 (易經大意 韓長庚)
- alter table新增字段操作究竟有何影响?(上篇)
- C#之敲击回车键触发Button的Click事件
- matlab非线性数值方程的求解
- 地理课(geography)
- uni-app 上拉加载函数 onReachBottom 不触发
- Jexus V5.0 正式发布
- Android之控件阴影模糊效果死磕Paint.setShadowLayer()
- 开一间“大宝剑”店能挣多少钱?
热门文章
- 液晶电视局部发黑怎么修?盘点几种液晶电视显示问题维修的方法
- 学习笔记-有效决策七步法
- PyTorch学习笔记:nn.ReLU——ReLU激活函数
- 8848万元智能手机如何突出重围?
- 【kibana】 kibana报错内存溢出 CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
- 软件项目实施步骤图解
- BZOJ 1191: [HNOI2006]超级英雄Hero 二分图匹配
- os+rom+android+6.0+n9005,三星N9005刷机包 Aurora.Note3.Full.Note5.Port.No.8 重新调试系统底层 提升系统流畅度...
- 链表删除的逻辑思想--流程图
- 使用VFW开发视频采集软件