数据结构课程设计停车管理系统实验报告.docx

上传人:b****1 文档编号:12791303 上传时间:2023-04-22 格式:DOCX 页数:17 大小:198.99KB
下载 相关 举报
数据结构课程设计停车管理系统实验报告.docx_第1页
第1页 / 共17页
数据结构课程设计停车管理系统实验报告.docx_第2页
第2页 / 共17页
数据结构课程设计停车管理系统实验报告.docx_第3页
第3页 / 共17页
数据结构课程设计停车管理系统实验报告.docx_第4页
第4页 / 共17页
数据结构课程设计停车管理系统实验报告.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

数据结构课程设计停车管理系统实验报告.docx

《数据结构课程设计停车管理系统实验报告.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计停车管理系统实验报告.docx(17页珍藏版)》请在冰豆网上搜索。

数据结构课程设计停车管理系统实验报告.docx

数据结构课程设计停车管理系统实验报告

数据结构课程设计报告

项目名称:

停车管理系统

安徽大学

计算机科学与技术学院

姓名:

鉏飞祥

学号:

E21414018

专业:

软件工程

2016-6-28

 

1.需求分析

 1.1问题描述

停车场只有一个可停放n辆汽车的狭长通道,且只有一个大门可供汽车进出。

汽车在停车场按车辆到达时间的先后顺序,依次由北向南排列(大门在最南端,最先到达的第一辆车停放在停车场的最北端),若车场已停满n辆汽车,则后来的汽车只能在门外的便道上等候,一旦有车开走,则排在便道上的第一辆车即可开入;当停车场某辆车要离开时,在它之后开入的车辆必须先退出车场为它让路,待该辆车开出大门外,其它车辆再按原次序进入车场,每辆停放在车场的车在它离开停车场时必须按它停留的时间长短交纳费用。

试为停车场编制按上述要求进行管理的模拟程序。

 1.2基本要求

(1)输入的形式和输入值的围;

七位字符车牌号空格时间(12:

30)

如:

A12345612:

30

(2)输出的形式;

车牌号时间

如:

A12345612:

30

(3)程序所能达到的功能。

模拟车子排队和进出车库的情况,并且根据时间计费,随时显示当前车库车辆情况。

2.概要设计 

(1) 数据结构 

每个汽车的基本元素:

structcar

{

charid[8];

inth;/*时*/

intm;/*分*/

structcar*next;

};

栈的基本元素:

structsqstack

{

structcar*base;

structcar*top;

intstacksize;

};

(2)程序模块

voidintstack(structsqstack&S)/*构造栈*/

voidpush_stack(structsqstack&S,structcar*e)

/*e入栈*/

voidpop_stack(structsqstack&S,structcar*e)

/*出栈顶元素到e*/

voidcreat_q()/*创建队列*/

voidpush_q(structcar*p)/*车辆入队*/

structcar*pop_q()/*车辆出队*/

voidcome_in()/*车辆离开*/

voidgo_out()/*车辆进入*/

voidinterface()/*主菜单*/

 

(4)各模块之间的调用关系以及算法设计

 

Return0

 

3.详细设计

流程图及模块调用如下:

主菜单

22

输出车库车辆

车辆进入

栈是否满

进入队列

进入栈

车辆离开

是否在栈中

是否在队列

找不到

元素出列

显示费用

结束程序

 

0

3

21

 

 

 

4.测试与分析

主界面如下:

车库中假设最多停三辆车,加入进入四辆车abcd,则d需要在便道排队:

此时若b车开走,显示费用信息,则在便道的d车进入车库:

若此时有车进入,则继续在便道排队

5.附录

源程序清单:

#include

#include

#include

#include

#defineMAX3/*宏定义车库最大车辆*/

structcar

{

charid[8];

inth;/*时*/

intm;/*分*/

structcar*next;

};

intn=0;/*当前车库的车辆数*/

intm=0;/*当前便道的车辆数*/

structcar*p1;

structsqstack

{

structcar*base;

structcar*top;

intstacksize;

};

structsqstackS1,S2;

 

voidintstack(structsqstack&S)

{

S.base=(structcar*)malloc(MAX*sizeof(structcar));

S.top=S.base;

S.stacksize=MAX;

}

voidpush_stack(structsqstack&S,structcar*e)

{

strcpy(S.top->id,e->id);

S.top->h=e->h;

S.top->m=e->m;

S.top++;

}

voidpop_stack(structsqstack&S,structcar*e)

{

 

S.top--;

strcpy(e->id,S.top->id);

e->h=S.top->h;

e->m=S.top->m;

 

}

voidcreat_q()

{

p1=(structcar*)malloc(sizeof(structcar));

p1->next=NULL;

}

voidpush_q(structcar*p)

{

structcar*p2;

p2=p1;

while(p2->next!

=NULL)

{

p2=p2->next;

}

p2->next=p;

p->next=NULL;

}

structcar*pop_q()

{

structcar*p;

p=p1->next;

p1->next=p1->next->next;

returnp;

}

voidcome_in()

{

voidinterface();

printf("请输入7位车辆车牌号和进入时间\n例如:

\nA12345612:

30\n");

if(n==MAX)

{

structcar*p;

p=(structcar*)malloc(sizeof(structcar));

scanf("%s",p->id);

scanf("%d:

%d",&p->h,&p->m);

push_q(p);

m++;

}

else

{

structcar*p;

p=(structcar*)malloc(sizeof(structcar));

scanf("%s",p->id);

scanf("%d:

%d",&p->h,&p->m);

push_stack(S1,p);

n++;

}

interface();

}

voidgo_out()

{

structcar*pop_q();

voidinterface();

printf("请输入7位车牌号和离开时间\n");

charb[8];

inth1;

intm1;

scanf("%s",b);

scanf("%d:

%d",&h1,&m1);

inti;

intbiaozhi=0;

for(i=0;i

{

if(strcmp(b,(S1.base+i)->id)==0)

{

printf("%s已离开\n计费信息:

\n进入时间%d:

%d,离开时间%d:

%d,(每分钟1元)\n",b,(S1.base+i)->h,(S1.base+i)->m,h1,m1);

printf("费用为:

%d元\n",(60*(h1-(S1.base+i)->h)+m1-(S1.base+i)->m)*1);

 

intj;

for(j=0;j

{

structcar*p2;

p2=(structcar*)malloc(sizeof(structcar));

pop_stack(S1,p2);

push_stack(S2,p2);

}

structcar*pp;

pop_stack(S2,pp);

for(j=1;j

{

pop_stack(S2,pp);

push_stack(S1,pp);

printf("222\n");

}

n--;

biaozhi=1;

if(p1->next!

=NULL)/*若便道有车,则便道的车进入车库*/

{

structcar*ppp;

ppp=pop_q();

push_stack(S1,ppp);

n++;

}

break;

}

}

if(biaozhi==0)

{

structcar*p,*pp;

pp=p1;

while(pp->next!

=NULL)

{

p=pp;

pp=pp->next;

if(strcmp(b,pp->id)==0)

{

printf("%s已离开\n",b);

printf("%s已离开\n计费信息:

\n进入时间%d:

%d,离开时间%d:

%d,(每分钟1元)\n",b,pp->h,pp->m,h1,m1);

printf("费用为:

%d元\n",(60*(h1-pp->h)+m1-pp->m)*1);

p->next=pp->next;

m--;

biaozhi=1;

break;

}

}

}

if(biaozhi==0)

printf("找不到%s\n",b);

interface();

}

voidprint()

{

voidpush_stack(structsqstackS,structcar*e);

voidpop_stack(structsqstackS,structcar*e);

voidinterface();

if(n==0)

printf("没有车辆\n");

else

{

printf("**车库现有车辆信息:

\n");

inti;

for(i=0;i

printf("%s%d:

%d\n",(S1.base+i)->id,(S1.base+i)->h,(S1.base+i)->m);

structcar*p;

p=p1;

if(p->next==NULL)

printf("**便道无车辆\n");

else

{

printf("**便道现有车辆信息:

\n");

while(p->next!

=NULL)

{

p=p->next;

printf("%s%d:

%d\n",p->id,p->h,p->m);

}

}

}

interface();

}

voidinterface()

{

inti;

printf("请输入操作指令\n\n1:

汽车开入\n2:

车辆离开\n3:

显示当前车辆信息\n0:

结束程序\n*******************\n");

scanf("%d",&i);

switch(i)

{

case0:

return;break;

case1:

come_in();break;

case2:

go_out();break;

case3:

print();break;

};

}

intmain()

{

system("colora0");//可以写成red调出颜色组

system("title车库管理系统");//设置cmd窗口标题

printf("****************欢迎使用停车管理系统*********************\n\n");

system("date/T");

system("TIME/T");

creat_q();

intstack(S1);

intstack(S2);

interface();

return0;

}

6.用户使用手册

欢迎使用车辆管理系统。

输入1,表示车辆进入

输入七位车牌号和进入时间,如:

A12378912:

30

输入2,表示车辆离开

输入离开车牌号和时间

输入3,表示显示车库信息

输入0,结束程序

使用!

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1