当前位置:文档之家› C C++ 停车场管理系统

C C++ 停车场管理系统

{
return (Q.rear-Q.front+MAXQSIZE)%MAXQSIZE;
}
Status w_total(SqQueue Q)
{
return QueueLength(Q);
};/*在便车道的车辆总数*/
Status EnQueue(SqQueue &Q,int e)
{
if((Q.rear+1)%MAXQSIZE==Q.front)
typedef struct LNode
{
struct
{
int stnumber;
char num[10];
struct now_time reach;
struct now_time leave;
float fee;
int totalhour;
}data;
struct LNode *next;
}LNode,*LinkList;
停车场管理系统
某停车场可以停放n辆汽车,该停车场只有一个大门,每辆汽车离开停车场都要求之前的汽车必须先退出停车场为它让道,而后让道的汽车再次驶入停车场,停车场示意图如下:
要求设计停车管理系统,实现车辆的进入、离开并根据停车时间计费。
程序:
#include <stdio.h>
#include <stdlib.h>
printf( "离开时间%d:%d:%d\n", newtime->tm_mday,newtime->tm_hour,newtime->tm_min);
printf( "您的停车费用总共:%f",fee);
printf("\n\n------------------------------\n\t*******谢谢您的光临,祝您一路平安********!\n\n");
{
int j=0,m=0,k;
int a=0;
for(int i=0;num[i]!='\0';i++)
{
j++;
}
for(i=1;i<=MAX;i++)
{
if(strcmp(set[i].num,num)==0)
{
m=1;
break;
}
}
if(j!=3||m==1)
return 1;
else
return 0;
{
p=p->next;
++j;
}
if(!p||j>i-1)
return ERROR;
s=(LinkList)malloc(sizeof(LNode));
s->data.fee=fee;
s->data.totalhour=totalhour;
s->data.stnumber=lset;
s->data.leave.mday=day;
Status Push(SqStack &S,int e)
{
if(S.top-S.base>=S.stacksize)
{
if(!S.base)
exit(OVERFLOW);
S.top=S.base+S.stacksize;
}
*S.top++=e;
return OK;
}
void enterstop( LinkList clist,SqStack &S,char number[10],int *come)
#include<string.h>
#include <time.h>
#define OK 1
#define NULL 0
#define ERROR 0
#define TURE 1
#define FALSE 0
#define OVERFLOW -2
typedef int Status;
#define MAXQSIZE 100
{
int e;
*come=*come+1;
Pop(S,e);
set[e].setnumber=e;
copy(set[e].num,number);
struct tm *newtime;
char am_pm[] = "AM";
time_t long_time;
time( &long_time ); /* Get time as long integer. */
int lset,t;
int j=1;
int totalhour;
float fee;
printf ("请输入您的车位号");
do{
scanf ("%d",&lset);
getchar();
for(int i=0;i<=MAX;i++)
{
if(set[lset].num[1]=='#')
j=0;
}
if(j==0)
printf("\n\n****请核对您的停车信息****\n");
printf("车牌号:%s\n",set[e].num);
printf("停车车位号:%d\n",set[e].setnumber);
printf( "到达时间%d:%d:%d\n", set[e].reach.mday,set[e].reach.hour,set[e].reach.min);
newtime = localtime( &long_time ); /* Convert to local time. */
set[e].reach.hour=newtime->tm_hour;
set[e].reach.mday=newtime->tm_mday;
set[e].reach.min=newtime->tm_min;
{
printf("*****车场并没有停车*******\n");
return ERROR;
}
else
{
if(lset>MAX ||lset<1)
{
printf("*****您输入有误,该车号并不存在!*******\n请重新输入您的车位号:\n");
t=1;
}
else
{
if(set[lset].num[1]=='#')
{
Q.base=(char*)malloc(100*sizeof(char[10]));
if(!Q.base)exit(OVERFLOW);
Q.front=Q.rear=0;
return OK;
}
/*模拟通道*/
Status stack_empty(SqStack S)
{
if(S.top==S.base)
fee=price*totalhour;
printf("****以下是您本次停车的信息****\n");
printf("车牌号:%s\n",set[lset].num);
printf("停车车位号:%d\n",set[lset].setnumber);
printf( "到达时间%d:%d:%d\n", set[lset].reach.mday,set[lset].reach.hour,set[lset].reach.min);
}
Status lListInsert_Link(LinkList &llist,int i,int lset,int totalhour,float fee,int day,int hour,int min)
{
LNode *p,*s;
int j;
p=llist;
j=0;
while(p&&j<i-1)
{
LNode *p,*s;
int j;
p=L;
j=0;
while(p&&j<i-1)
{
p=p->next;
++j;
}
if(!p||j>i-1)
return ERROR;
s=(LinkList)malloc(sizeof(LNode));
s->data.stnumber=set[setnumber].setnumber;
return ERROR;
Q.base[Q.rear]=e;
Q.rear=(Q.rear+1)%MAXQSIZE;
return OK;
}
Status enterlane(SqQueue &Q,int waitenumber)
{
EnQueue(Q,waitenumber);
return OK;
}/*进入便车道等待*/
s->next=p->next;
p->next=s;
return OK;
}
void ccord(LinkList clist,int i,int setnumber)
{
ListInsert_Link(clist,i,setnumber);
}
Status initStack(SqStack &S)
{
int i;
s->data.reach.hour=set[setnumber].reach.hour;
相关主题