c语言车辆管理系统课程设计Document serial number【UU89WT-UU98YT-UU8CB-UUUT-UUT108】#include<>#include<>#include<>#define MAX 3 /*车库容量*/#define price /*每车每分钟费用*/ typedef struct time{int hour;int min;}Time; /*时间结点*/typedef struct node{char num[10];Time reach;Time leave;}CarNode;/*车辆信息结点*/typedef struct NODE{CarNode *stack[MAX + 1];int top;}Moni_Cheku;typedef struct car{CarNode *data;struct car *next;}QueueNode;typedef struct Node{QueueNode *head;QueueNode *rear;}Moni_Biandao;void InitStack(Moni_Cheku *); /*初始化车库*/int InitQueue(Moni_Biandao *);/*初始化便道*/int Arrival(Moni_Cheku *, Moni_Biandao *); /*车辆到达*/void Leave(Moni_Cheku *, Moni_Cheku *, Moni_Biandao *); /*车辆离开*/void List(Moni_Cheku, Moni_Biandao); /*显示车库和便道的存车信息*/int main(){Moni_Cheku Enter, Temp;Moni_Biandao Wait;int ch;InitStack(&Enter); /*初始化车站*/InitStack(&Temp); /*初始化让路的临时链表*/InitQueue(&Wait); /*初始化便道*/printf("\n");printf(" ^_^欢迎进入停车场管理系统1!^_^\n");printf("\n");printf("提示! (1).该车库的最大容量为:%d;\n", MAX); printf(" (2).该车库的收费标准为:%元/(辆*分钟).\n", price);while (1){system("CLS");printf("********************主菜单********************\n");printf("1.车辆到达");printf(" 2.车辆离开");printf(" 3.列表显示");printf(" 4.退出系统\n");printf("**********************************************\n");printf("请选择(1-4):[ ]\b\b");while (1){scanf("%d",&ch);if (ch >= 1 && ch <= 4)break;else printf("错误!请重选(1-4):[ ]\b\b");}switch (ch){case 1:Arrival(&Enter, &Wait); break; /*车辆到达*/case 2:Leave(&Enter, &Temp, &Wait); break; /*车辆离开*/case 3:List(Enter, Wait); break; /*打印列表信息*/case 4:exit(0); /*退出主程序*/default: break;}}return 0;}void InitStack(Moni_Cheku *s) /*初始化车库*/{int i;s->top = 0;for (i = 0; i <= MAX; i++)s->stack[s->top] = NULL;}int InitQueue(Moni_Biandao *Q) /*初始化便道*/{Q->head = (QueueNode *)malloc(sizeof(QueueNode));if (Q->head != NULL){Q->head->next = NULL;Q->rear = Q->head;return(1);}else return(-1);}void PRINT(CarNode *p, int room) /*输出出库车的信息*/ {int A1, A2, B1, B2;{printf("请输入离开的时间:/**:**/");scanf("%d:%d", &(p->, &(p->);printf("离开车辆的车牌号为:");puts(p->num);printf("其到达时间为: %d:%d\n", p->, p->;printf("离开时间为: %d:%d\n", p->, p->;A1 = p->;A2 = p->;B1 = p->;B2 = p->;printf("应交费用为:%元", ((B1 - A1) * 60 + (B2 - A2))*price);free(p);}}int Arrival(Moni_Cheku *Enter, Moni_Biandao *W) /*车辆到达*/ {CarNode *p;QueueNode *t;p = (CarNode *)malloc(sizeof(CarNode));fflush(stdin);printf("请输入车牌号(例如:中CUG888):");scanf("%s",&(p->num));if (Enter->top < MAX) /*车库未满,车进车库*/{Enter->top++;printf("该车在车库位置%d.\n", Enter->top);printf("请输入到达时间(**:**):");scanf("%d:%d", &(p->, &(p->);Enter->stack[Enter->top] = p;return(1);}else /*车库已满,车进便道*/{printf("该车须在便道等待!\n");t = (QueueNode *)malloc(sizeof(QueueNode));t->data = p;t->next = NULL;W->rear->next = t;W->rear = t;return(1);}}void Leave(Moni_Cheku *Enter, Moni_Cheku *Temp, Moni_Biandao *W) /*车辆离开*/{int i, room;CarNode *p, *t;QueueNode *q;/*判断车库内是否有车*/if (Enter->top > 0) /*有车*/{printf("请输入车在车库的位置(1--%d):", Enter->top);/*输入车辆离开的信息*/while (1){scanf("%d", &room);if (room >= 1 && room <= Enter->top) break;else printf("错误!请重选:");}while (Enter->top > room) /*车辆离开*/{Temp->top++;Temp->stack[Temp->top] = Enter->stack[Enter->top];Enter->stack[Enter->top] = NULL;Enter->top--;}p = Enter->stack[Enter->top];Enter->stack[Enter->top] = NULL;Enter->top--;while (Temp->top >= 1){Enter->top++;Enter->stack[Enter->top] = Temp->stack[Temp->top];Temp->stack[Temp->top] = NULL;Temp->top--;}PRINT(p, room); /*判断通道上是否有车及车库是否已满*/if ((W->head != W->rear) && Enter->top < MAX) /*便道的车辆进入车库*/{q = W->head->next;t = q->data;Enter->top++;printf("\n便道的%s号车进入车场第%d位置.", t->num, Enter->top);printf("\n请输入现在的时间(**:**):");scanf("%d:%d", &(t->, &(t->);W->head->next = q->next;if (q == W->rear) W->rear = W->head;Enter->stack[Enter->top] = t;free(q);}else printf("\n便道里没有车.\n");}else printf("车库里没有车!\n"); /*没车*/}void List1(Moni_Cheku *S) /*列表显示车库信息*/{int i;if (S->top > 0) /*判断车库内是否有车*/{printf("车库号到达时间 \t车牌号\n");for (i = 1; i <= S->top; i++){printf(" %d ", i);printf(" \t%d:%d", S->stack[i]->, S->stack[i]->;printf("\t\t%s\n",S->stack[i]->num);}}else printf("车库里没有车\n");}void List2(Moni_Biandao *W) /*列表显示便道信息*/{QueueNode *p;p = W->head->next;if (W->head != W->rear) /*判断便道上是否有车*/{printf("在便道里等待的车辆的号码为:\n");while (p != NULL){puts(p->data->num);p = p->next;}}else printf("便道里没有车.\n");}void List(Moni_Cheku S, Moni_Biandao W){int flag, tag;flag = 1;while (flag){printf("**********查看**********\n");printf("1.车库2.便道3.返回\n");printf("************************\n");printf("请选择(1-3):[ ]\b\b");while (1){scanf("%d", &tag);if (tag >= 1 && tag <= 3) break;else printf("错误!请重选(1-3):[ ]\b\b");}switch (tag){case 1:List1(&S);break;/*列表显示车库信息*/case 2:List2(&W);break; /*列表显示便到信息*/case 3:flag = 0;break;default:break;}}}。