用栈和队列实现的停车场管理系统

停车场管理
问题描述:停车场是一个能放 n 辆车的狭长通道,只有一个大门,汽车按到达
的先后次序停放。若车场满了,车要停在门外的便道上等候,一旦有车走,则便
道上第一辆车进入。当停车场中的车离开时,由于通道窄,在它后面的车要先退
出,待它走后在依次进入。汽车离开时按停放时间收费。
基本功能要求:
(1) 建立三个数据结构分别是:停放栈、让路栈、等候队列。
(2) 输入数据模拟管理过程,数据(入或出,车号)。


#ifndef __PARK_H__

#define __PARK_H__


#define FALSE  0
#define TRUE   1


#define TIME  60
#define SIZE  10
#include "error.h"
#include <time.h>


//typedef int QueData;


typedef struct _quedata
{
int num;
time_t t_start;
time_t t_end;
}QueData;


typedef struct _parkqueue
{
QueData data[SIZE];
int front;
int rear;
}ParkQueue;


typedef struct _stack
{
QueData data[SIZE];
int top;
}Stack;






void Park(Stack *q, ParkQueue *p);


void Leave(Stack *q, ParkQueue *p, Stack *s);


void Look();


void Quit();


void Look(Stack *q, ParkQueue *p);


int GetFront(ParkQueue *q, int *x);


int QueueEmpty(ParkQueue *q);


int DeQueue(ParkQueue *q, int *x);


void MainInterface();


int InitStack(Stack *s);


void InitQueue(ParkQueue *q);


void Choice(int x,Stack *pq, ParkQueue *wq, Stack *s);


int QueueFull(ParkQueue *q);


int EnQueue(ParkQueue *q, int x);


int StackFull (Stack *s);


int Push (Stack *s, int x);


int Pop (Stack *s, int *x, float *t);


int StackEmpty (Stack *s);


int GetTop(Stack *s, int *x);


int Push2 (Stack *s, int x, float t);

#endif  //__PARK_H__






#include "Park.h"

#include <stdio.h>

#include <time.h>


void MainInterface()
{
system("clear");
printf("\t*************停车管理系统******************\n");
printf("\t*                                         *\n");
printf("\t*        1.停车                           *\n");
printf("\t*                                         *\n");
printf("\t*        2.离开                           *\n");
printf("\t*                                         *\n");
printf("\t*        3.查看停车场情况                 *\n");
printf("\t*                                         *\n");
printf("\t*        4.退出                           *\n");
printf("\t*                                         *\n");
printf("\t*******************************************\n");
printf("\n");
}


void Choice(int x, Stack *pq, ParkQueue *wq, Stack *s)
{
switch(x)
{
case 1:
MainInterfac

  • 0
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值