C語言停車場管理系統源代碼_第1頁
C語言停車場管理系統源代碼_第2頁
C語言停車場管理系統源代碼_第3頁
C語言停車場管理系統源代碼_第4頁
C語言停車場管理系統源代碼_第5頁
已閱讀5頁,還剩3頁未讀 繼續免費閱讀

下載本文檔

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

文檔簡介

1、精選優質文檔-傾情為你奉上#include<stdio.h>#include<stdlib.h>#define stacksize 2 /車站/容量/typedef struct Snode int number; float int_time2; float bian_time2;record;typedef struct record *base; record *top; int size;Stack;/typedef struct Qnode int number; float int_time2; struct Qnode *next;Qnode,*Queue

2、;typedef struct Queue front; Queue rear;Linkqueue;void xunhuan(Stack L,Linkqueue Q);void jixu(Stack L,Linkqueue Q);/void InitStack(Stack &L) /堆棧操作 L.base=(record*)malloc(sizeof(Snode)*stacksize); if(!L.base) exit(0); L.top=L.base; L.size=stacksize;/void input(Stack &L,record h) *L.top+=h; /S

3、node output(Stack &L,record &e) e=*-L.top; return e; int Stackman(Stack L) if(L.top-L.base=L.size) return 0; else return 1;int StackEmpty(Stack L) if(L.base=L.top) return 0; else return 1;/void Initque(Linkqueue &Q) /隊列操作 Q.front=Q.rear=(Queue)malloc(sizeof(Qnode); if(!Q.front) exit(0);

4、Q.front->next=NULL;/void enqueue(Linkqueue &Q,int number,float time) Queue q; printf("停車場已滿,請將車輛停入便道!n"); q=(Queue)malloc(sizeof(Qnode); q->int_time0=time0; q->int_time1=time1; q->number=number; q->next=NULL; Q.rear->next=q; Q.rear=q; /void outqueue(Linkqueue &Q,Q

5、ueue &e) /此處有點問題? / Qnode *q; /q=(Queue)malloc(sizeof(Qnode); e=Q.front->next; / Q.front->next=q->next;/delete q; Q.front->next=Q.front->next->next; if(Q.rear=e) Q.front=Q.rear; / Q.front=NULL; int QEmpty(Linkqueue Q) if(Q.rear=Q.front) return 0; else return 1;/ /停車場管理操作/void j

6、ixu(Stack L,Linkqueue Q)int n; fflush(stdin); scanf("%d",&n);switch(n)case 1:printf("nn");xunhuan(L,Q); break;case 2:printf("*退出管理系統*n"); break;default:printf("n輸入錯誤,請重新輸入: ");jixu(L,Q);break;void jiaofei(float time,float time1,float time2) /繳費操作 float dat

7、a1,data2;double money;if(time20!=0&&time21!=0) data2=(time10-time20-1)*60+60-time21+time11;elsedata2=0;data1=(time0-time10-1)*60+60-time11+time1;/printf("進入車場時間%f,退出車場時間%fn",time11,time1);printf("你的停車時間為%lf小時 ,在便道停留時間%f小時n",data1/60,data2/60); money=data1/60*5.0+data2/60*

8、2.0; printf("請交納%lf元n",money); /* if(data1<=60.0)printf("請交納5元。");if(data1>60.0&&data1<=120.0)printf("請交納10元。");if(data1>120.0)printf("請交納20元。");*/void leave(Stack &L,Linkqueue &Q,int number,float time) /汽車離開操作Stack S;InitStack(S);f

9、loat time12,time22; record e,e1;Queue q; e1=output(L,e); while(e.number!=number) input(S,e1); e1=output(L,e); time10=_time0; /入車站時間time11=_time1;time20=e.bian_time0; /入便道時間time21=e.bian_time1; jiaofei(time,time1,time2); / while(StackEmpty(S) input(L,output(S,e1); while(QEmpty(Q)&&S

10、tackman(L) outqueue(Q,q); /printf("nn請輸入汽車從便道進入停車場的時間,輸入格式為(時 空格 分):"); e.bian_time0=q->int_time0; e.bian_time1=q->int_time1; /scanf("%f %f",&time20,&time21); _time0=time0; _time1=time1; e.number=q->number; printf("n汽車從便道退出進入停車場"); printf(&quo

11、t;n請將%d號車停在%d號位置!n",e.number,L.top-L.base+1); input(L,e); /void xunhuan(Stack L,Linkqueue Q) /選擇操作及循環/Queue q; char ch; int number; float time2,time22; fflush(stdin); printf("nA:進入停車場 D:退出停車場 E:退出管理系統n"); printf("n請輸入:"); scanf("%c",&ch);fflush(stdin); switch(c

12、h) case 'A': printf("n請輸入車牌號: "); scanf("%d",&number); printf("請輸入入場時間,輸入格式為(時 空格 分):"); scanf("%f %f",&time0,&time1); if(Stackman(L) record e; _time0=time0; _time1=time1; e.bian_time0=0.0; e.bian_time1=0.0; e.number=number; print

13、f("請將車停在%d號位置!",L.top-L.base+1); input(L,e); else enqueue(Q,number,time); printf("n"); printf("n1、繼續操作 2、退出操作 : "); jixu(L,Q); break; case 'D': if(StackEmpty(L) printf("請輸入離開汽車的車牌號:"); scanf("%d",&number); printf("輸入汽車離開時間:"); s

14、canf("%f %f",&time20,&time21); leave(L,Q,number,time2); else printf("停車場為空n"); printf("n1、繼續操作 2、退出操作 : "); jixu(L,Q); break; case 'E': printf("*退出管理系統*n"); break; default: printf("輸入錯誤,請重新輸入!n"); printf("#n"); xunhuan(L,Q); break; /void main() /主函數操作 Linkqueue Q; Stack L; InitStack(L); Init

溫馨提示

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

評論

0/150

提交評論