失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 停车场系统管理c语言程序代码 停车场管理系统程序源代码

停车场系统管理c语言程序代码 停车场管理系统程序源代码

时间:2024-01-09 17:37:56

相关推荐

停车场系统管理c语言程序代码 停车场管理系统程序源代码

一个简单的停车场管理系统c语言代码

#include

#include

#define N 30 /*停车场类最多的停车数*/

#define M 20 /*便道内最多的停车数*/

#define price 2 /*每单位时间的停车费用*/

typedef struct

{

int carNo[N]; /*车牌号*/

int carTime[N]; /*进场时间*/

int top; /*栈指针*/

}seqstack; /*定义顺栈占类型*/

typedef struct Node

{

int carNo[M]; /*车牌号*/

struct Node *next;

}linkQueue Node;

typedef struct

{

LinkQueue Node *front; /*队首指针*/

LinkQueue Node *rear; /*队尾指针*/

}LinkQueue; /*定义链队类型*/

/*以下是顺序栈的基本运算算法*/

void Initstack(seqstack *s)

{

s=(seqstack*)malloc(sizeof(seqstack));

s->top=-1;

}

int IsEmpt(seqstack *s)

{

return(s->top==-1);

}

int IsFull(seqstack *s)

{

return(s->top==N-1);

}

int Push(seqstack *s,int e1,int e2)

{

if(s->top==N-1) return 0;

s->top++;

s->carNo[s->top]=e1;

s->carTime[s->top]=e2;

return 1;

}

int Pop(seqstack *s,int &e1,int &e2)

{

if(s->top==-1)

return 0;

e1=s->carNo[s->top];

e2=s->carTime[s->top];

s->top--;

return 1;

}

void Disqstack(seqstack *s)

{

int i;

for(i=s->top;i>=0;i--)

printf("%d",s->carNo[i]);

printf("\n");

}

/*以下是链队的基本运算算法*/

int InitQueue(LinkQueue *q)

{

q->front=(LinkQueue Node *)malloc(sizeof(LinkQueue Node));

if(q->front!=NULL)

{

q->rear=q->front;

q->front->next=NULL;

return(true);

}

else return(false);

}

int Empt(LinkQueue *q) /*判队满*/

{

return(q->front==q->rear);

}

int Lull(LinkQueue *q)

{

return((q-a.rear+1)%M==q->front);

}

int EnterQueue(LinkQueue *&q,int e) /*进队*/

{

if((q->rear+1)%M==q->front) /*队满*/

return 0;

q->rear=(q->rear+1)%M;

q->carNo[q->rear]=e;

return 1;

}

int DeleteQueue(LinkQueue *&q,int &e) /*出队*/

{

if(q->front==q->rear) /*对空情况*/

return 0;

q->front=(q->front+1)%M;

e=q->carNo[q->front];

return 1;

}

void DispQueue(LinkQueue *q) /*输出队中元素*/

{

int i;

i=(q->front+1)%M;

printf("%d",q->carNo[i];

while((q->rear-i+M)%M>0)

{

i=(i+1)%M;

printf("%d",q->carNo[i]);

}

printf("\n");

}

void main()

{

int comm;

int No,e1,Time,e2;

int i,j;

seqstack *st1,*st2;

LinkQueue *qu;

Initstack(st)

Initstack(st1);

InitQueue(Qu);

do

{printf("input a number(1:到达 2:离开 3:停车场 4:便道 0退出):");

scanf("%d%d%d",&comm,&no,&time);

switch(comm)

{

case 1; /*汽车到达*/

if(!stackFull(st)) /*便道不满*/

{

Push(st,n

o,time);

printf(">>停车场位置:%d\n",st->top+1);

}

else /*停车场满*/

{

if(!QueueFull(Qu)) /*便道不满*/

{

EnterQueue(Qu,no);

pr

如果觉得《停车场系统管理c语言程序代码 停车场管理系统程序源代码》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。