C C++ 停车场管理系统.docx

上传人:小飞机 文档编号:3060439 上传时间:2023-03-10 格式:DOCX 页数:14 大小:40.35KB
返回 下载 相关 举报
C C++ 停车场管理系统.docx_第1页
第1页 / 共14页
C C++ 停车场管理系统.docx_第2页
第2页 / 共14页
C C++ 停车场管理系统.docx_第3页
第3页 / 共14页
C C++ 停车场管理系统.docx_第4页
第4页 / 共14页
C C++ 停车场管理系统.docx_第5页
第5页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《C C++ 停车场管理系统.docx》由会员分享,可在线阅读,更多相关《C C++ 停车场管理系统.docx(14页珍藏版)》请在三一办公上搜索。

1、C C+ 停车场管理系统停车场管理系统 某停车场可以停放n辆汽车,该停车场只有一个大门,每辆汽车离开停车场都要求之前的汽车必须先退出停车场为它让道,而后让道的汽车再次驶入停车场,停车场示意图如下: 要求设计停车管理系统,实现车辆的进入、离开并根据停车时间计费。 程序: #include #include #include #include #define OK 1 #define NULL 0 #define ERROR 0 #define TURE 1 #define FALSE 0 #define OVERFLOW -2 typedef int Status; #define MAXQSI

2、ZE 100 #define MAX 3/*车库容量*/ #define price 0.05 /*每车每分钟费用*/ struct now_time int mday; int hour; int min; ; struct information int setnumber; char num10; struct now_time reach; struct now_time leave; setMAX+1;/*车位信息*/ typedef struct char *base; int front; int rear; SqQueue; typedef struct int *base;

3、int *top; int stacksize; SqStack; typedef struct LNode struct int stnumber; char num10; struct now_time reach; struct now_time leave; float fee; int totalhour; data; struct LNode *next; LNode,*LinkList; void copy(char *a,char *b) int i; for(i=0;(ai=bi)!=0;i+); void CreateList_L(LinkList &L) L=(LinkL

4、ist) malloc (sizeof(LNode); L-next=NULL; Status is_long(char *num) int j=0,m=0,k; int a=0; for(int i=0;numi!=0;i+) j+; for(i=1;i=MAX;i+) if(strcmp(seti.num,num)=0) m=1; break; if(j!=3|m=1) return 1; else return 0; Status lListInsert_Link(LinkList &llist,int i,int lset,int totalhour,float fee,int day

5、,int hour,int min) LNode *p,*s; int j; p=llist; j=0; while(p&jnext; +j; if(!p|ji-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; s-data.leave.hour=hour; s-data.leave.min=min; copy(s-data.num,setlset.num); s-n

6、ext=p-next; p-next=s; return OK; Status ListInsert_Link(LinkList &L,int i,int setnumber) LNode *p,*s; int j; p=L; j=0; while(p&jnext; +j; if(!p|ji-1) return ERROR; s=(LinkList)malloc(sizeof(LNode); s-data.stnumber=setsetnumber.setnumber; s-data.reach.hour=setsetnumber.reach.hour; s-data.reach.mday=s

7、etsetnumber.reach.mday; s-data.reach.min=setsetnumber.reach.min; copy(s-data.num,setsetnumber.num); 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.base=(int * )malloc(MAX * sizeof(int); if(!

8、S.base)exit(OVERFLOW); S.top=S.base; S.stacksize=MAX; for(i=1;i=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 number10,int *come) int e; *come=*come+1; Pop(S,e); sete.setnumber=e; copy(sete.num,number); struct

9、tm *newtime; char am_pm = AM; time_t long_time; time( &long_time ); /* Get time as long integer. */ newtime = localtime( &long_time ); /* Convert to local time. */ sete.reach.hour=newtime-tm_hour; sete.reach.mday=newtime-tm_mday; sete.reach.min=newtime-tm_min; printf(nn*请核对您的停车信息*n); printf(车牌号:%sn,

10、sete.num); printf(停车车位号:%dn,sete.setnumber); printf( 到达时间%d:%d:%dn, sete.reach.mday,sete.reach.hour,sete.reach.min); ccord(clist,*come,sete.setnumber); /*进入停车场*/ Status DeQueue(SqQueue &Q) if(Q.front=Q.rear) return ERROR; Q.front=(Q.front+1)%MAXQSIZE; return OK; Status EmptyQueue(SqQueue Q) if(Q.fro

11、nt=Q.rear) return OK; else return ERROR; Status leavestop(LinkList llist,LinkList clist,SqStack &S,SqQueue &Q,int *come,int*leave) char number10; int lset,t; int j=1; int totalhour; float fee; printf (请输入您的车位号); do scanf (%d,&lset); getchar; for(int i=0;iMAX |lsettm_mday-setlset.reach.mday)*24*60+(n

12、ewtime-tm_hour-setlset.reach.hour)*60+(newtime-tm_min-setlset.reach.min); fee=price*totalhour; printf(*以下是您本次停车的信息*n); printf(车牌号:%sn,setlset.num); printf(停车车位号:%dn,setlset.setnumber); printf( 到达时setlset.reach.mday,setlset.reach.hour,setlset.reach.min); 间%d:%d:%dn, printf( 离开时间%d:%d:%dn, newtime-tm_

13、mday,newtime-tm_hour,newtime-tm_min); printf( 您的停车费用总共:%f,fee); printf(nn-nt*谢谢您的光临,祝您一路平安*!nn); printf(nnnntttmention:press any key continue!); getchar; system(cls); *leave=*leave+1; lListInsert_Link(llist,*leave,lset,totalhour,fee,newtime-tm_mday,newtime-tm_hour,newtime-tm_min); setlset.num1=#; Pu

14、sh(S,lset); if(!EmptyQueue(Q) DeQueue(Q); printf(n请停在停车便道的客户进入停车场!nn输入您的车牌号(例:川A1):n); scanf(%s,number); while(is_long(number) printf(n请重新输入您的车牌号(例:川A1):); scanf(%s,number); enterstop(clist,S,number,come); t=0; else t=0; while(t=1); return OK; /*离开停车场*/ void showcome(LinkList clist) LNode *p; p=clis

15、t-next; while(p) printf(n%st%d号t%d日%d时%d分,p-data.num,p-data.stnumber,p-data.reach.mday,p-data.reach.hour,p-data.reach.min); p=p-next; void showleave(LinkList clist) LNode *p; p=clist-next; while(p) printf(n%st%d号t%d日%d时%d,p-data.num,p-data.stnumber,p-data.leave.mday,p-data.leave.hour,p-data.leave.mi

16、n); p=p-next; float total_fee(LinkList list) LNode *p; p=list-next; float total_fee=0; while(p) total_fee+=p-data.fee; p=p-next; 分 return total_fee; int total_hour(LinkList list) LNode *p; p=list-next; int total_hour=0; while(p) total_hour=total_hour+p-data.totalhour; p=p-next; return total_hour; /*

17、-*/ void main int choice,wset,ture=1; int i,wchoice; int leave=0,come=0; int *p1; p1=&come; int *p2; p2=&leave; char number10; SqStack stack_set; SqQueue queue_turn; initStack(stack_set); /*初始化车站*/ initQueue(queue_turn); /*初始化通道*/ LinkList llist;/*离开连表*/ LinkList clist;/*到达连表*/ CreateList_L(llist);

18、CreateList_L(clist); for(i=1;itm_year,newtime-tm_mon,newtime-tm_mday ); 年%d月%d日 printf(n-n到达车辆一共:t%d辆,come); printf (n车牌号t车位号 t到达时间t); showcome(clist); printf(n-n离开车辆一共:t%d辆,leave); printf (n车牌号t车位号 t离开时间t); showleave(llist); printf(nnn总计时间:%d,total_hour(llist); printf(nnn总计收费:%f,total_fee(llist); b

19、reak; case 1: if(!stack_empty(stack_set) printf(n请输入您的车牌号(例:川A1):); scanf(%s,number); while(is_long(number) printf(n请重新输入您的车牌号(例:川A1):); scanf(%s,number); enterstop(clist,stack_set,number,p1); /*调用进入停车场模块*/ else wset=w_total(queue_turn); printf(*您好,当前停车场已满,有%d在等待!*n您是否愿意进入便车道等待:n1:愿意等待!tt2:不愿意等待n ,w

20、set); while(ture=1) scanf(%d,&wchoice); getchar; switch(wchoice) case 1: enterlane(queue_turn,wset);/*调用汽车进入便车道模块*/ printf(*您好,请进入便车道等待*!); ture=0; break; case 2: printf(n汽车离开!); ture=0; break; default: printf(n您好,输入错误,请重新输入!); ;ture=1; break; case 2: leavestop(llist,clist,stack_set,queue_turn,p1,p2);/*调用汽车从停车场离开*/ break; case 9: printf(退出停车系统!n); break; default : printf(您输入的有误,请重新输入:); getchar; while(choice!=9);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号