停车场.docx

上传人:b****3 文档编号:5961099 上传时间:2023-05-09 格式:DOCX 页数:8 大小:16.02KB
下载 相关 举报
停车场.docx_第1页
第1页 / 共8页
停车场.docx_第2页
第2页 / 共8页
停车场.docx_第3页
第3页 / 共8页
停车场.docx_第4页
第4页 / 共8页
停车场.docx_第5页
第5页 / 共8页
停车场.docx_第6页
第6页 / 共8页
停车场.docx_第7页
第7页 / 共8页
停车场.docx_第8页
第8页 / 共8页
亲,该文档总共8页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

停车场.docx

《停车场.docx》由会员分享,可在线阅读,更多相关《停车场.docx(8页珍藏版)》请在冰点文库上搜索。

停车场.docx

停车场

数学与计算机学院数据结构实验报告

年级08级学号姓名成绩

专业实验地点主楼402指导教师

实验项目停车场管理系统实验日期12.10

一、实验题目

停车场管理

【问题描述】设停车场内只有一个可停放n辆汽车的狭长通道,且只有一个大门可供汽车进出。

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

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

二、需求分析

⑴.使用的相关开发工具:

MicrosoftVisualC++6.0

⑵.输入的形式:

字符类型数据

输入值的范围:

字符型数据

输出的形式:

字符型数据

⑶程序所能达到的功能

实现停车场的管理,输入车牌号码,将此车停入停车站,并展示出来,在另一个编辑框中输入车牌号,将此车开出停车站。

若停车站已满,则在便道中展示出来。

(4)测试数据:

停车牌号:

123车库:

123便道:

(空)

12341234

出车牌号:

1234车库:

123便道:

(空)出车情况:

1234

三、程序流程图略

四、数据结构及算法描述

数据结构

ypedefstructparting

{

CStringchepai;

clock_tstart;

}PART;

typedefstructwaiting

{

CStringchepai;

clock_tstart,finish;

structwaiting*next;

}WAIT;

typedefstruct

{

WAIT*front,*rear;

}Lwait;

算法描述

BOOLCpart:

:

add(CStringchepai)

{

BOOLflg=true;

if(i>=N)flg=false;

else

{

parting[i].chepai=chepai;

parting[i].start=clock();

i++;

}

returnflg;

}

voidCpart:

:

display(CListBox*list)

{

CStringstr,xs;

list->ResetContent();

list->InsertString(0,"车位车牌号");

for(intm=0;m

{

str="";

xs.Format("%-3d",m);

str+=xs+"";

xs=parting[m].chepai;

str+=xs;

list->InsertString(m+1,str);

}

}

voidCpart:

:

adding(CStringchepai)

{

if(q->front->next==NULL)

{

WAIT*p=newWAIT;

p->next=NULL;

q->front=q->rear=p;

}

p=newWAIT;

p->next=NULL;

p->chepai=chepai;

q->rear->next=p;

q->rear=p;

}

voidCpart:

:

disp(CListBox*list)

{

CStringstr,xs;

list->ResetContent();

list->InsertString(0,"车牌号");

intm=0;

for(WAIT*p=q->front->next;p;p=p->next)

{

str="";

xs.Format("%s",p->chepai);

str+=xs;

list->InsertString(++m,str);

}

}

//DELvoidCpart:

:

del(intn)

//DEL{

//DEL

//DEL}

//DELWAIT*Cpart:

:

head()

//DEL{

//DEL

//DEL}

//DELWAIT*Cpart:

:

head()

//DEL{

//DEL

//DEL}

voidCpart:

:

pop()

{

parting[i].chepai=head->next->chepai;

parting[i].start=head->next->start;

i++;

WAIT*p;

p=head->next;

head->next=p->next;

deletep;

}

voidCpart:

:

push()

{

p=newWAIT;

p->next=NULL;

i--;

p->chepai=parting[i].chepai;

p->start=parting[i].start;

p->next=head->next;

head->next=p;

}

 

voidCpart:

:

out()

{

parting[i].chepai=q->front->next->chepai;

parting[i].start=clock();

i++;

WAIT*m=q->front->next;

q->front->next=m->next;

deletem;

}

voidCpart:

:

push2()

{

WAIT*m;

m=newWAIT;

m->next=NULL;

i--;

m->chepai=parting[i].chepai;

m->start=parting[i].start;

m->finish=clock();

p2->next=m;

p2=m;

}

voidCpart:

:

disp2(CListBox*list)

{

CStringstr,xs;

list->ResetContent();

list->InsertString(0,"车牌号停车时间停车收费");

intm=0;

for(WAIT*mm=head2->next->next;mm;mm=mm->next)

{

str="";

xs.Format("%-s",mm->chepai);

str+=xs;

xs.Format("%6ds",((mm->finish-mm->start)/1000));

str+=""+xs;

xs.Format("%6.2f元",((mm->finish-mm->start)/1000)*0.003);

str+=""+xs;

list->InsertString(++m,str);

}

}

五、调试分析

⑴出站函数难以实现,通过老师的帮助得以解决。

⑵算法时间复杂度:

O(n).

⑶改进思想:

导入图片,便于直观理解。

⑷经验体会:

平时要多读程序,注意和老师同学交流。

六、使用说明

在“停车牌号”处连续输入车牌号,单击“停车”按钮,可使此车挺入停车站,若停车站已满则停入便道。

在“出车牌号”处输入车牌号,单击“出车”按钮,当没有此车时,可见提示框“没有此车”,若有此车,可见“停车站”“便道”和“停车情况”列表框实现相应变化

七、测试结果

停车牌号:

123车库:

123便道:

(空)

12341234

出车牌号:

1234车库:

123便道:

(空)出车情况:

1234

停车牌号:

123车库:

123便道:

12

12341234

1234512345

12

出车牌号:

1234车库:

123便道:

(空)出车情况:

12345s0.01元

12345

12

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

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2