停车场停车
来源:互联网 发布:linux创建用户默认组 编辑:程序博客网 时间:2024/04/25 08:41
//这是一个简单的停车场作业,目前为止只能实现停车,剩下的代码有问题,还在解决中,就先不拿出来了
#include"Parking.h"
#include<stdio.h>
void menu()
{
system("clear");
printf("***********************************************************************\n");
printf("* *\n");
printf("* Welcome to our park *\n");
printf("* *\n");
printf("* 1 : 停 车 *\n");
printf("* 2 : 离 开 *\n");
printf("* 3 : 查 看 *\n");
printf("* 4 : 退 出 *\n");
printf("* *\n");
printf("* 请输入需要的操作(1-4): *\n");
printf("* MADE BY SUBAOXUN *\n");
printf("* *\n");
printf("***********************************************************************\n");
}
//创建停车场队列与等候队列
int InitQueue (ParkQueue *p)
{
if(p==NULL)
{
errno = ERROR;
return FALSE;
}
p->front=0;
p->rear=0;
return TRUE;
}
//创建等候区队列
/*
int InitQueue (ParkQueue *w)
{
if(w==NULL)
{
errno = ERROR;
return FALSE;
}
w->front=0;
w->rear=0;
return TRUE;
}
*/
//停车场是否为空
int QueueEmpty (ParkQueue *p)
{
if (p == NULL)
{
errno = ERROR;
return FALSE;
}
return p->front == p->rear;
}
//停车场是否停满
int QueueFull (ParkQueue *p)
{
if (p == NULL)
{
errno = ERROR;
return FALSE;
}
return p->front == (p->rear+1)%SIZE;
}
//进停车场
int EnQueue (ParkQueue *p, QueueData x)
{
if (p == NULL)
{
errno = ERROR;
return FALSE;
}
if (QueueFull(p))
{
errno = FULL_QUEUE;
return FALSE;
}
p->rear = (p->rear+1) % SIZE;
p->data[p->rear] = x;
return TRUE;
}
//出停车场
int DeQueue (ParkQueue *p, QueueData *x)
{
if (p == NULL)
{
errno = ERROR;
return FALSE;
}
if (QueueEmpty(p))
{
errno = EMPTY_QUEUE;
return FALSE;
}
p->front = (p->front + 1) % SIZE;
*x = p->data[p->front];
return TRUE;
}
//让路栈
int InitStack (Stack *S)
{
if (S == NULL)
{
errno = ERROR;
return FALSE;
}
S->top = -1;
}
// 空返回真,否则返回假
int StackEmpty (Stack *S)
{
if (S == NULL)
{
errno = ERROR;
return FALSE;
}
return S->top == -1;
}
// 满返回真,否则返回假
int StackFull (Stack *s)
{
if (s == NULL)
{
errno = ERROR;
return FALSE;
}
return s->top == (SIZE-1);
}
int Push (Stack *s, StackData x)
{
if (s == NULL)
{
errno = ERROR;
return FALSE;
}
// 判断是否满栈
if (StackFull(s))
{
errno = FULL_STACK;
return FALSE;
}
/*
s->data[top+1] = x;
s->top++;
*/
s->data[++s->top] = x;
return TRUE;
}
//出栈
int Pop (Stack *s, StackData *x)
{
if (s == NULL)
{
errno = ERROR;
return FALSE;
}
// 判断是否空栈
if (StackEmpty(s))
{
errno = EMPTY_STACK;
return FALSE;
}
/*
*x = s->data[s->top];
s->top--;
*/
*x = s->data[s->top--];
return TRUE;
}
//停车函数
int Parking(ParkQueue *p,ParkQueue *w)
{
if(p==NULL)
return FALSE;
if(w==NULL)
return FALSE;
if(QueueFull(p)==TRUE)
{
printf("停车场已满\n");
//此时就需要把车停在便道等待区里
int numw;
printf("请输入车牌号: ");
scanf("%d",&numw);
EnQueue (w, numw);
}
else
{
int num;
printf("请输入车牌号:\n");
scanf("%d",&num);
EnQueue (p, num);
}
}
- 停车场停车
- JAVA多线程模拟停车场停车
- 停车场自动停车,取车创意
- 三种停车致损 停车场不赔偿
- 杭州地铁首末站周边停车场正酝酿停车收费优惠
- 支付宝又出黑科技,停车场不停车通过
- 停车栈让路栈等候队列完成停车场项目
- 停车
- 使用php开发停车场系统,智能停车系统,php程序源码
- 停车场
- 停车场
- 停车场
- 停车场
- 停车场
- 停车场
- 停车场
- 停车场
- 停车管理
- Vue-router导航钩子
- 前端必备基础知识
- 前后端联调实践总结
- PHP中的排序函数sort、asort、rsort、krsort、ksort区别分析
- strcpy、strncpy、memcpy的区别
- 停车场停车
- Red and Black(DFS)
- kubernetes学习记录(1)——kubernetes初理解
- C/C++ & JAVA 内存布局
- H5里面背景图片的设置
- strcmp的使用
- 仿朋友圈图片显示
- Pots
- 201412-2