云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 数据结构课程设计 停车场管理系统

数据结构课程设计 停车场管理系统

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 7:54:24

s->stack[s->top]=NULL; }

int InitQueue(LinkQueueCar *Q) /*初始化便道*/ { Q->head=(QueueNode *)malloc(sizeof(QueueNode)); if(Q->head!=NULL) { Q->head->next=NULL; Q->rear=Q->head; return(1); }

else return(-1); }

int Arrival(SeqStackCar *Enter,LinkQueueCar *W) /*车辆到达*/ { CarNode *p; QueueNode *t;

p=(CarNode *)malloc(sizeof(CarNode)); flushall();

cout<<\请输入车牌号(例:A1234):\ gets(p->num);

if(Enter->toptop++;

cout<<\车辆在车场第\位置!\ cout<<\请输入到达时间:(小时:分钟)\ cin>>p->reach.hour; while(p->reach.hour<0||p->reach.hour>23) //控制时间格式正确 { cout<<\输入错误!\

cout<<\请重输入到达时间的时(0-23)!\ cin>>p->reach.hour; } cin>>p->reach.min;

while(p->reach.min<0||p->reach.min>59) //控制分钟输入正确 { cout<<\输入错误!\

cout<<\请重输入到达时间的分(0-59)!\ cin>>p->reach.min; }

Enter->stack[Enter->top]=p; return(1); }

9

else /*车场已满,车进便道*/ { cout<<\车场已满,请在便道等待!\ t=(QueueNode *)malloc(sizeof(QueueNode)); t->data=p;

t->next=NULL; W->rear->next=t; W->rear=t; return(1); } }

void Leave(SeqStackCar *Enter,SeqStackCar *Temp,LinkQueueCar *W) /*车辆离开*/ {

int room; CarNode *p; QueueNode *q;

/*判断车场内是否有车*/ if(Enter->top>0) /*有车*/ { while(1) /*输入离开车辆的信息*/ { cout<<\请输入车在车场的位置1--\ cin>>room;

if(room>=1&&room<=Enter->top) break; }

while(Enter->top>room) /*车辆离开*/ { Temp->top++; /*临时通道栈顶指针*/

Temp->stack[Temp->top]=Enter->stack[Enter->top]; Enter->stack[Enter->top]=NULL; Enter->top--; }

p=Enter->stack[Enter->top];

Enter->stack[Enter->top]=NULL; Enter->top--;

while(Temp->top>=1) /*判断临时通道上是否有车*/ { Enter->top++;

Enter->stack[Enter->top]=Temp->stack[Temp->top]; Temp->stack[Temp->top]=NULL; Temp->top--;} PRINT(p,room);

if((W->head!=W->rear)&&Enter->top

10

q=W->head->next;

p=q->data; /*p指向链队头*/ Enter->top++;

cout<<\便道的\号车进入车场第\位置!\

cout<<\请输入现在的时间如(小时:分钟):\ cin>>p->reach.hour;

if(p->reach.hour<0||p->reach.hour>23) { cout<<\输入错误!\

cout<<\请重输入到达时间的时(0-23)!\ cin>>p->reach.hour; } cin>>p->reach.min;

if(p->reach.min<0||p->reach.min>59) { cout<<\输入错误!\

cout<<\请重输入到达时间的分(0-59)!\ cin>>p->reach.min; } Enter->stack[Enter->top]=p; W->head->next=q->next;

if(q==W->rear) W->rear=W->head;

free(q); /*释放q地址*/ }

else cout<<\便道里没有车!\ /*便道没车*/ }

else cout<<\车场里没有车!\车场没车*/ }

void PRINT(CarNode *p,int room) /*输出离开车辆的信息清单*/ { int A1,A2,B1,B2;

cout<<\请输入离开的时间:(小时:分钟)\ cin>>p->leave.hour;

while(p->leave.hour<0||p->leave.hour>23) { cout<<\输入错误!\

cout<<\请重输入离开的时间的时(0-23)\ cin>>p->leave.hour; B1=p->leave.hour; }

11

cin>>p->leave.min; if(p->leave.min<0||p->leave.min>59) { cout<<\输入错误!\

cout<<\请重输入到达时间的分(0-59)!\ cin>>p->leave.min; }

cout<num);

cout<<\其到达时间为: \ cout<<\离开时间为: \ A1=p->reach.hour; A2=p->reach.min; B1=p->leave.hour; B2=p->leave.min; cout<<\应交费用为: \元!\ free(p); }

void List1(SeqStackCar *S) /*列表显示车场信息*/ { cout<<\您选择的是车场停车情况!\ int i;

if(S->top>0) /*判断车站内是否有车*/ {

cout<<\位置 到达时间 车牌号\ for(i=1;i<=S->top;i++) { cout<<\ \ \ \ } }

else cout<<\车场里没有车!\}

void List2(LinkQueueCar *W) /*列表显示便道信息*/ { cout<<\您选择的是便道停车情况!\ int j=1; QueueNode *p; p=W->head->next;

if(W->head!=W->rear) /*判断通道上是否有车*/ { cout<<\等待车辆的车牌号码为:\ while(p!=NULL)

12

{ //cout<data->num); cout<next; j++; } //开始时显示不正确,没有按照正常输出 }

else cout<<\便道里没有车!\}

void List(SeqStackCar S,LinkQueueCar W) /*列表界面*/ { int flag,tag; flag=1;

while(flag) /*列表显示循环控制*/ { cout<<\请选择您要显示信息! (1-3):\ cout<<\※--1.车场--※\ cout<<\※--2.便道--※\ cout<<\※--3.返回--※\ while(1) { cin>>tag;

if(tag>=1||tag<=3) break;

else cout<<\输入错误!请选择 (1-3):\ } switch(tag) { case 1:List1(&S);break; /*列表显示车场信息*/ case 2:List2(&W);break; /*列表显示便道信息*/ case 3:flag=0;break; default: break; } } }

13

搜索更多关于: 数据结构课程设计 停车场管理系统 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

s->stack[s->top]=NULL; } int InitQueue(LinkQueueCar *Q) /*初始化便道*/ { Q->head=(QueueNode *)malloc(sizeof(QueueNode)); if(Q->head!=NULL) { Q->head->next=NULL; Q->rear=Q->head; return(1); } else return(-1); } int Arrival(SeqStackCar *Enter,LinkQueueCar *W) /*车辆到达*/ { CarNode *p; QueueNode *t; p=(CarNode *)malloc(sizeof

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com