中南民族大学数据结构课程设计停车场管理系统内容摘要:

d carin(Sqstack amp。 S,LinkQueue amp。 Q,Elem car)//进场函数 { int k=0。 //检测信号,当值为 k=0时表示栈和队中都找不到该车牌号 QueuePtr r。 Elem *temp。 temp=。 //赋值为栈底 while(temp!=) { if(tempcarnum==)//在栈中寻找是否有同一编号的车 { cout该车号在停车场中已存在,请重新输入 !endl。 k=1。 //找到了有同一编号的车 break。 } temp++。 } if(k==0amp。 amp。 !=)//如果在栈中未找到,在队列中查找 { r=next。 //队头 while(ramp。 amp。 r!=) { r=rnext。 //找不到继续找 } if(ramp。 amp。 r==) { cout该车号在车道中已存在 ,请重新输入 !endl。 k=1。 } } if(k==0)//栈和队列中都找不到相同车牌号,执行入栈操作; { if(!=)//栈未满, { carnum=。 time=。 ++。 couttempcarnum 号车于 时刻进入停车场lengthstack(S)号车位。 endl。 } else { enqueue(Q,)。 //栈满已满,把车安排在车道队列中 cout 停 车 场 已 满 , 请 号 车 在 便 车 道lengthqueue(Q)稍等。 endl。 } } } void carleave(Sqstack amp。 S,LinkQueue amp。 Q,Elem car)//车辆退出函数 { int ture=0。 //在栈中没有找到与要离开的车 Elem e,em,*temp。 QueuePtr p,r。 temp=。 if(ture==0) { while(temp!=)//先在栈中寻找; { if(tempcarnum==) { int temp_cost。 temp_cost=(time)*price。 ture=1。 //在栈中找到 cout号车在 时刻离开,停车时间为 time刻钟,应交停车费用为: temp_costendl。 break。 } temp++。 } if(ture==1) //备用栈 { Sqstack spear。 initStack(spear)。 while(!=temp+1)//先在栈中寻找; { pop(S,em)。 push(spear,em)。 } pop(S,*temp)。 //其他车退出停车场暂存在零时栈 if(!=) { while(!=) { pop(spear,em)。 push(S,em)。 } } } if(ture==1amp。 amp。 !=)//栈中有车离开,将队列中的车进入栈中 { dequeue(Q,e)。 //离队,并返回数据 e carnum=。 time=。 ++。 cout请便道的第一辆车 牌号为 的车辆转入停车场,停车位置为 lengthstack(S)号 ,停车时刻为: endl。 } } if(ture==0amp。 amp。 !=)//栈中没找到要离开的车 { p=。 r=next。 //队头 while(ramp。 amp。 r!=) { p=r。 r=rnext。 } if(ramp。 amp。 r==)//在队列中找到要离开的车 { ture=2。 cout便道 r号车离开 ,不收取费用。 endl。 pnext=rnext。 free(r)。 } }//直接从队列离开 if(ture==0) cout没有该辆车 !endl。 } int main() { char c。 int j=0,temp_time,i=1。 //i==0,判断临时记录时间的 temp_time 应该去该次的值,还是上次的值。 j==0,表示第一次输入数据,不需要检测数据是否正确 LinkQueue Q。 Sqstack S。 Elem car。 initqueue (Q)。 initStack(S)。 ifstream infile。 cout欢迎使用停车场管理系统。 endl。 cout请稍等。 信息正在载入183。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。