c語(yǔ)言車(chē)輛管理系統(tǒng)課程設(shè)計(jì)報(bào)告書(shū)_第1頁(yè)
c語(yǔ)言車(chē)輛管理系統(tǒng)課程設(shè)計(jì)報(bào)告書(shū)_第2頁(yè)
c語(yǔ)言車(chē)輛管理系統(tǒng)課程設(shè)計(jì)報(bào)告書(shū)_第3頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、#include<stdio.h>#include<stdlib.h>#include<string.h>#defineMAX3/*車(chē)庫(kù)容量*/#defineprice0.5/*每車(chē)每分鐘費(fèi)用*/typedefstructtimeinthour;intmin;Time;/*時(shí)間結(jié)點(diǎn)*/typedefstructnodecharnum10;Timereach;Timeleave;CarNode;/*車(chē)輛信息結(jié)點(diǎn)*/typedefstructNODECarNode*stackMAX+1;inttop;Moni_Cheku;typedefstructcar(Car

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

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

4、X);printf("(2).該車(chē)庫(kù)的收費(fèi)標(biāo)準(zhǔn)為:%4.2f元/(輛*分鐘).n",price);while(1)system("CLS");printf(主菜單*n");printf("1.車(chē)輛到達(dá)”);printf("2.車(chē)輛離開(kāi)");printf("3.列表顯示");n");printf("4.退出系統(tǒng)n");printf(printf("請(qǐng)選擇(1-4):bb");while(1)(scanf("%d”,&ch);if(

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

6、s)/*初始化車(chē)庫(kù)*/(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)/*輸出出庫(kù)車(chē)的信息*/intA1,A

7、2,B1,B2;printf("請(qǐng)輸入離開(kāi)的時(shí)間:/*:*/");scanf("%d:%d”,&(p->leave.hour),&(p->leave.min);printf("離開(kāi)車(chē)輛的車(chē)牌號(hào)為:");puts(p->num);printf("其到達(dá)時(shí)間為:%d:%dn",p->reach.hour,p->reach.min);printf("離開(kāi)時(shí)間為:%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("應(yīng)交費(fèi)用為:4.2f元",(B1-A1)*60+(B2-A2)*price);free(p);intArrival(Moni_Cheku*Enter,Moni_Biandao*W)/*車(chē)輛到達(dá)*/(CarNode*p;QueueNode*t;p=(CarNode*)malloc(sizeof(CarNode);fflush(stdin);printf("請(qǐng)輸入車(chē)牌號(hào)(例如:中CUG888):");scanf

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

10、f("該車(chē)須在便道等待!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)/*車(chē)輛離開(kāi)*/(inti,room;CarNode*p,*t;QueueNode*q;/*判斷車(chē)庫(kù)內(nèi)是否有車(chē)*/if(Enter->top>0)/*有車(chē)*/(printf("請(qǐng)輸入車(chē)

11、在車(chē)庫(kù)的位置(1-%d):",Enter->top);/*輸入車(chē)輛離開(kāi)的信息*/while(1)(scanf("%d",&room);if(room>=1&&room<=Enter->top)break;elseprintf("錯(cuò)誤!請(qǐng)重選:");while(Enter->top>room)/*車(chē)輛離開(kāi)*/(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);/*判斷通道上是否有車(chē)及車(chē)庫(kù)是否已滿*/if(W->head!

13、=W->rear)&&Enter->top<MAX)/*便道的車(chē)輛進(jìn)入車(chē)庫(kù)*/(q=W->head->next;t=q->data;Enter->top+;printf("n便道的號(hào)車(chē)進(jìn)入車(chē)場(chǎng)第%d位置.”,t->num,Enter->top);printf("n請(qǐng)輸入現(xiàn)在的時(shí)間(*:*):");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便道里沒(méi)有車(chē).n”);elseprintf("車(chē)庫(kù)里沒(méi)有車(chē)!n");/*沒(méi)車(chē)*/voidList1(Moni_Cheku*S)/*列表顯示車(chē)庫(kù)信息*/inti;if(S->top>0)/*判斷車(chē)庫(kù)內(nèi)是否有車(chē)*/printf("車(chē)庫(kù)號(hào)到達(dá)時(shí)間t車(chē)牌號(hào)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("車(chē)庫(kù)里沒(méi)有車(chē)n");voidList2(Moni_Biandao*W)/*列表顯示便道信息*/(QueueNode*p;p=W->head->next;if(W->head!=W->rear)/*判斷便道上是否有車(chē)*/(printf("在便道里等待的車(chē)輛的號(hào)碼為:n");while(p!=NULL)(puts(p->data->num);p=p->next;elseprintf("便道里沒(méi)有車(chē).n”);voidList(Moni_ChekuS,Moni_BiandaoW)(intflag,tag;flag=1;while(flag)printf(查看*n");printf("1.車(chē)庫(kù)2.便道3.返回n");printf("*n");printf("請(qǐng)

溫馨提示

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

評(píng)論

0/150

提交評(píng)論