c語言車輛管理系統課程設計報告書_第1頁
c語言車輛管理系統課程設計報告書_第2頁
c語言車輛管理系統課程設計報告書_第3頁
已閱讀5頁,還剩2頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、#include<stdio.h>#include<stdlib.h>#include<string.h>#defineMAX3/*車庫容量*/#defineprice0.5/*每車每分鐘費用*/typedefstructtimeinthour;intmin;Time;/*時間結點*/typedefstructnodecharnum10;Timereach;Timeleave;CarNode;/*車輛信息結點*/typedefstructNODECarNode*stackMAX+1;inttop;Moni_Cheku;typedefstructcar(Car

2、Node*data;structcar*next;QueueNode;typedefstructNode(QueueNode*head;QueueNode*rear;Moni_Biandao;voidInitStack(Moni_Cheku*);/*初始化車庫*/intInitQueue(Moni_Biandao*);/*初始化便道*/intArrival(Moni_Cheku*,Moni_Biandao*);/*車輛到達*/voidLeave(Moni_Cheku*,Moni_Cheku*,Moni_Biandao*);/*車輛離開*/voidList(Moni_Cheku,Moni_Bia

3、ndao);/*顯示車庫和便道的存車信息*/intmain()(Moni_ChekuEnter,Temp;Moni_BiandaoWait;intch;InitStack(&Enter);/*初始化車站*/InitStack(&Temp);/*初始化讓路的臨時鏈表*/InitQueue(&Wait);/*初始化便道*/printf("n");printf("A_A歡迎進入停車場管理系統1!A_An");printf("n");printf("提示!(1).該車庫的最大容量為:%d;n",MA

4、X);printf("(2).該車庫的收費標準為:%4.2f元/(輛*分鐘).n",price);while(1)system("CLS");printf(主菜單*n");printf("1.車輛到達”);printf("2.車輛離開");printf("3.列表顯示");n");printf("4.退出系統n");printf(printf("請選擇(1-4):bb");while(1)(scanf("%d”,&ch);if(

5、ch>=1&&ch<=4)break;elseprintf("錯誤!請重選(1-4):bb");switch(ch)(case1:Arrival(&Enter,&Wait);break;/*車輛到達*/case2:Leave(&Enter,&Temp,&Wait);break;/*車輛離開*/case3:List(Enter,Wait);break;/*打印列表信息*/case4:exit(0);/*退出主程序*/default:break;return0;voidInitStack(Moni_Cheku*

6、s)/*初始化車庫*/(inti;s->top=0;for(i=0;i<=MAX;i+)s->stacks->top=NULL;intInitQueue(Moni_Biandao*Q)/*初始化便道*/Q->head=(QueueNode*)malloc(sizeof(QueueNode);if(Q->head!=NULL)Q->head->next=NULL;Q->rear=Q->head;return(1);elsereturn(-1);voidPRINT(CarNode*p,introom)/*輸出出庫車的信息*/intA1,A

7、2,B1,B2;printf("請輸入離開的時間:/*:*/");scanf("%d:%d”,&(p->leave.hour),&(p->leave.min);printf("離開車輛的車牌號為:");puts(p->num);printf("其到達時間為:%d:%dn",p->reach.hour,p->reach.min);printf("離開時間為:%d:%dn",p->leave.hour,p->leave.min);A1=p->re

8、ach.hour;A2=p->reach.min;B1=p->leave.hour;B2=p->leave.min;printf("應交費用為:4.2f元",(B1-A1)*60+(B2-A2)*price);free(p);intArrival(Moni_Cheku*Enter,Moni_Biandao*W)/*車輛到達*/(CarNode*p;QueueNode*t;p=(CarNode*)malloc(sizeof(CarNode);fflush(stdin);printf("請輸入車牌號(例如:中CUG888):");scanf

9、("%s",&(p->num);if(Enter->top<MAX)/*車庫未滿,車進車庫*/Enter->top+;printf("該車在車庫位置%d.n",Enter->top);printf("請輸入到達時間(*:*):");scanf("%d:%d",&(p->reach.hour),&(p->reach.min);Enter->stackEnter->top=p;return(1);else/*車庫已滿,車進便道*/(print

10、f("該車須在便道等待!n");t=(QueueNode*)malloc(sizeof(QueueNode);t->data=p;t->next=NULL;W->rear->next=t;W->rear=t;return(1);voidLeave(Moni_Cheku*Enter,Moni_Cheku*Temp,Moni_Biandao*W)/*車輛離開*/(inti,room;CarNode*p,*t;QueueNode*q;/*判斷車庫內是否有車*/if(Enter->top>0)/*有車*/(printf("請輸入車

11、在車庫的位置(1-%d):",Enter->top);/*輸入車輛離開的信息*/while(1)(scanf("%d",&room);if(room>=1&&room<=Enter->top)break;elseprintf("錯誤!請重選:");while(Enter->top>room)/*車輛離開*/(Temp->top+;Temp->stackTemp->top=Enter->stackEnter->top;Enter->stackEnter

12、->top=NULL;Enter->top-;p=Enter->stackEnter->top;Enter->stackEnter->top=NULL;Enter->top-;while(Temp->top>=1)(Enter->top+;Enter->stackEnter->top=Temp->stackTemp->top;Temp->stackTemp->top=NULL;Temp->top-;PRINT(p,room);/*判斷通道上是否有車及車庫是否已滿*/if(W->head!

13、=W->rear)&&Enter->top<MAX)/*便道的車輛進入車庫*/(q=W->head->next;t=q->data;Enter->top+;printf("n便道的號車進入車場第%d位置.”,t->num,Enter->top);printf("n請輸入現在的時間(*:*):");scanf("%d:%d”,&(t->reach.hour),&(t->reach.min);W->head->next=q->next;if(q

14、=W->rear)W->rear=W->head;Enter->stackEnter->top=t;free(q);elseprintf("n便道里沒有車.n”);elseprintf("車庫里沒有車!n");/*沒車*/voidList1(Moni_Cheku*S)/*列表顯示車庫信息*/inti;if(S->top>0)/*判斷車庫內是否有車*/printf("車庫號到達時間t車牌號n");for(i=1;i<=S->top;i+)printf("%d",i);pri

15、ntf("t%d:%d”,S->stacki->reach.hour,S->stacki->reach.min);printf("tt%sn",S->stacki->num);elseprintf("車庫里沒有車n");voidList2(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;elseprintf("便道里沒有車.n”);voidList(Moni_ChekuS,Moni_BiandaoW)(intflag,tag;flag=1;while(flag)printf(查看*n");printf("1.車庫2.便道3.返回n");printf("*n");printf("請

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論