c語(yǔ)言車輛管理系統(tǒng)課程設(shè)計(jì)_第1頁(yè)
c語(yǔ)言車輛管理系統(tǒng)課程設(shè)計(jì)_第2頁(yè)
c語(yǔ)言車輛管理系統(tǒng)課程設(shè)計(jì)_第3頁(yè)
c語(yǔ)言車輛管理系統(tǒng)課程設(shè)計(jì)_第4頁(yè)
c語(yǔ)言車輛管理系統(tǒng)課程設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩8頁(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/*車庫(kù)容量*/#defineprice0.5/*每車每分鐘費(fèi)用*/typedefstructtimeinthour;intmin;Time;/*時(shí)間結(jié)點(diǎn)*/typedefstructnodecharnum10;Timereach;Timeleave;CarNode;/*車輛信息結(jié)點(diǎn)*/typedefstructNODECarNode*stackMAX+1;inttop;Moni_Cheku;typedefstructcarCarN

2、ode*data;structcar*next;QueueNode;typedefstructNodeQueueNode*head;QueueNode*rear;Moni_Biandao;voidInitStack(Moni_Cheku*);/*初始化車庫(kù)*/intInitQueue(Moni_Biandao*);/*初始化便道*/intArrival(Moni_Cheku*,Moni_Biandao*);/*車輛到達(dá)*/voidLeave(Moni_Cheku*,Moni_Cheku*,Moni_Biandao*);/*車輛離開*/voidList(Moni_Cheku,Moni_Biand

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

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

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

6、ni_Cheku*s)/*初始化車庫(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ù)車的信息*

7、/intA1,A2,B1,B2;printf("請(qǐng)輸入離開的時(shí)間:/*:*/");scanf("%d:%d",&(p->leave.hour),&(p->leave.min);printf("離開車輛的車牌號(hào)為:");puts(p->num);printf("其到達(dá)時(shí)間為:%d:%dn",p->reach.hour,p->reach.min);printf("離開時(shí)間為:%d:%dn",p->leave.hour,p->leave.min

8、);A1=p->reach.hour;A2=p->reach.min;81 =p->leave.hour;82 =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)/*車輛到達(dá)*/CarNode*p;QueueNode*t;p=(CarNode*)malloc(sizeof(CarNode);fflush(stdin);printf("請(qǐng)輸入車牌號(hào)(例如:中CUG888

9、):");scanf("%s",&(p->num);if(Enter->top<MAX)/*車庫(kù)未滿,車進(jìn)車庫(kù)*/Enter->top+;printf("該車在車庫(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/*車庫(kù)

10、已滿,車進(jìn)便道*/printf("該車須在便道等待!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;/*判斷車庫(kù)內(nèi)是否有車*/if(Enter->top>0)/*有車*/print

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

12、stackEnter->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);/*判斷通道上是否有車及車庫(kù)是否已滿*/if(W-

13、>head!=W->rear)&&Enter->top<MAX)/*便道的車輛進(jìn)入車庫(kù)*/q=W->head->next;t=q->data;Enter->top+;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=W->rear)W->rear=W->

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

15、S->stacki->reach.hour,S->stacki->reach.min);printf("tt%sn",S->stacki->num);elseprintf("車庫(kù)里沒有車n");voidList2(Moni_Biandao*W)/*列表顯示便道信息*/QueueNode*p;p=W->head->next;if(W->head!=W->rear)/*判斷便道上是否有車*/printf("在便道里等待的車輛的號(hào)碼為: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.車庫(kù)2.便道3.返回n");printf("*n");printf("請(qǐng)選擇(1-3):

溫馨提示

  • 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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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)論