停车场管理
问题描述:停车场是一个能放 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