停车场管理系统源代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
elsereturn ERROR;
}
//入栈
int Push(SqStack &S,Car e){
if(S.top-S.base==S.stacksize) return ERROR;
*S.top++=e;
return OK;
}
//出栈
int Pop(SqStack &S,Car &e){
if(S.top==S.base) return ERROR;
return OK;
}
//判空
int StackEmpty(SqStack S){
if(S.top==S.base) return OK;
elsereturn ERROR;
}
//判满
int StackFull(SqStack S){
if(S.top-S.base>=S.stacksize) return OK;
printf("\t\t位置:%d",l++);
printf("\n");
q++;
}
return OK;
}
//备用车道(顺序栈)
typedef struct {
Car2 *top2;
Car2 *base2; //
int stacksize2;
}SqStack2;
//初始化
int InitStack2(SqStack2 &S2){
}
//出队
int DeQueue(LinkQueue &Q,Car &e){
QueuePtr p;
if(Q.front==Q.rear) return ERROR;
p=Q.front->next;
e=p->data;
Q.front->next=p->next;
delete p;
return OK;
}
else return ERROR;
}
//进栈
int Push2(SqStack2 &S2,Car2 e2){
if(S2.top2-S2.base2==STACKSIZE) return ERROR;
*S2.top2++=e2;
return OK;
}
//出栈
int Pop2(SqStack2 &S2,Car2 &e2){
//主函数
int main(){
int i=1;
int j=1;
int status;
float time,money;
LinkQueue Q;
Car car_I,car_D,car_M;
SqStack S;
SqStack2 S2;
InitStack(S);
InitStack2(S2);
InitQueue(Q);
Car *base;
int stacksize;
}SqStack;
//初始化
int InitStack(SqStack &S){
S.base=new Car[STACKSIZE];
if(!S.base) exit(OVERFLOW);
S.top=S.base;
S.stacksize=STACKSIZE;
//停车场管理系统
#include<stdio.h>
#include<stdlib.h>
#define OVERFLOW 0
#define ERROR 0
#define OK 1
#define STACKSIZE 2 //车库容量
//时间节点
typedef struct time{
int hour;
QueuePtr front;
QueuePtr rear;
}LinkQueue;Biblioteka Baidu
//初始化
int InitQueue(LinkQueue &Q){
Q.front=Q.rear=new QNode;
Q.front->next=NULL;
return OK;
}
//进队
int EnQueue(LinkQueue &Q,Car e){
int min;
}Time;
//车辆信息
typedef struct{
char CarNum;
float time;
int pos_a; //车在停车场中的位置
int pos_b;//车在便道上的位置
int flag;
}Car,Car2;
//车库信息(顺序栈)
typedef struct{
Car *top;
while(1){
printf("\t\t\t欢迎来到XXX停车场!\n");
printf("*****************************************************************\n");
QueuePtr p;
p=new QNode;
p->data=e;
p->next=NULL;
Q.rear->next=p;
Q.rear=p;
return OK;
}
//判空
int QueueEmpty(LinkQueue Q){
if(Q.front==Q.rear) return OK;
else return ERROR;
e=*--S.top;
return OK;
}
//遍历栈
int StackTraverse(SqStack S) {
Car *p=S.top;
Car *q=S.base;
int l=1;
if(StackEmpty(S)){
for(int j=1;j<=STACKSIZE;j++){
printf("\t车牌:");
printf("\t\t到达时间:");
printf("\t位置%d:空空",j);
printf("\n");
}
return OK;
}
while(p!=q){
Car car=*(q);
printf("\t车牌: %d",car.CarNum);
printf("\t\t到达时间:%5.2f",car.time);
if(S2.top2==S2.base2) return ERROR;
e2=*--S2.top2;
return OK;
}
//车道信息(链队)
typedef struct QNode{
Car data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct{
S2.base2=new Car2[STACKSIZE];
if(!S2.top2) exit(OVERFLOW); //
S2.top2=S2.base2;
S2.stacksize2=STACKSIZE;
return OK;
}
//判空
int StackEmpty2(SqStack2 S2){
if(S2.top2==S2.base2) return OK;
}
//入栈
int Push(SqStack &S,Car e){
if(S.top-S.base==S.stacksize) return ERROR;
*S.top++=e;
return OK;
}
//出栈
int Pop(SqStack &S,Car &e){
if(S.top==S.base) return ERROR;
return OK;
}
//判空
int StackEmpty(SqStack S){
if(S.top==S.base) return OK;
elsereturn ERROR;
}
//判满
int StackFull(SqStack S){
if(S.top-S.base>=S.stacksize) return OK;
printf("\t\t位置:%d",l++);
printf("\n");
q++;
}
return OK;
}
//备用车道(顺序栈)
typedef struct {
Car2 *top2;
Car2 *base2; //
int stacksize2;
}SqStack2;
//初始化
int InitStack2(SqStack2 &S2){
}
//出队
int DeQueue(LinkQueue &Q,Car &e){
QueuePtr p;
if(Q.front==Q.rear) return ERROR;
p=Q.front->next;
e=p->data;
Q.front->next=p->next;
delete p;
return OK;
}
else return ERROR;
}
//进栈
int Push2(SqStack2 &S2,Car2 e2){
if(S2.top2-S2.base2==STACKSIZE) return ERROR;
*S2.top2++=e2;
return OK;
}
//出栈
int Pop2(SqStack2 &S2,Car2 &e2){
//主函数
int main(){
int i=1;
int j=1;
int status;
float time,money;
LinkQueue Q;
Car car_I,car_D,car_M;
SqStack S;
SqStack2 S2;
InitStack(S);
InitStack2(S2);
InitQueue(Q);
Car *base;
int stacksize;
}SqStack;
//初始化
int InitStack(SqStack &S){
S.base=new Car[STACKSIZE];
if(!S.base) exit(OVERFLOW);
S.top=S.base;
S.stacksize=STACKSIZE;
//停车场管理系统
#include<stdio.h>
#include<stdlib.h>
#define OVERFLOW 0
#define ERROR 0
#define OK 1
#define STACKSIZE 2 //车库容量
//时间节点
typedef struct time{
int hour;
QueuePtr front;
QueuePtr rear;
}LinkQueue;Biblioteka Baidu
//初始化
int InitQueue(LinkQueue &Q){
Q.front=Q.rear=new QNode;
Q.front->next=NULL;
return OK;
}
//进队
int EnQueue(LinkQueue &Q,Car e){
int min;
}Time;
//车辆信息
typedef struct{
char CarNum;
float time;
int pos_a; //车在停车场中的位置
int pos_b;//车在便道上的位置
int flag;
}Car,Car2;
//车库信息(顺序栈)
typedef struct{
Car *top;
while(1){
printf("\t\t\t欢迎来到XXX停车场!\n");
printf("*****************************************************************\n");
QueuePtr p;
p=new QNode;
p->data=e;
p->next=NULL;
Q.rear->next=p;
Q.rear=p;
return OK;
}
//判空
int QueueEmpty(LinkQueue Q){
if(Q.front==Q.rear) return OK;
else return ERROR;
e=*--S.top;
return OK;
}
//遍历栈
int StackTraverse(SqStack S) {
Car *p=S.top;
Car *q=S.base;
int l=1;
if(StackEmpty(S)){
for(int j=1;j<=STACKSIZE;j++){
printf("\t车牌:");
printf("\t\t到达时间:");
printf("\t位置%d:空空",j);
printf("\n");
}
return OK;
}
while(p!=q){
Car car=*(q);
printf("\t车牌: %d",car.CarNum);
printf("\t\t到达时间:%5.2f",car.time);
if(S2.top2==S2.base2) return ERROR;
e2=*--S2.top2;
return OK;
}
//车道信息(链队)
typedef struct QNode{
Car data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct{
S2.base2=new Car2[STACKSIZE];
if(!S2.top2) exit(OVERFLOW); //
S2.top2=S2.base2;
S2.stacksize2=STACKSIZE;
return OK;
}
//判空
int StackEmpty2(SqStack2 S2){
if(S2.top2==S2.base2) return OK;