1、 if(stack = NULL) return NULL; stack-count = 0;top = NULL; return stack;void push(Stack *stack,void *data) nodeS *node; node = new nodeS; if(node = NULL | stack = NULL) return ; node-data = data;link = stack-top;top = node;count+;void* pop(Stack *stack) if(stack-count = 0) data = stack-top-data; nod
2、e = stack-top = node-link;count-; return data;void DestroyStack(Stack *stack) while(stack- delete stack- node = stack- stack- delete stack;Que *CreateQueue() Que *queue; queue = new Que; if(queue = NULL) queue-front = NULL;rear = NULL; return queue;void Enqueue(Que *queue) nodeQ *node; node = new no
3、deQ; if(node = NULL | queue = NULL)next = NULL; if(queue- queue-front = node; elserear-next = node;rear = node;void *Dequeue(Que *queue) dataptr = queue-front-dataptr;count = 1)front = queue- elsenext; return dataptr;void Destroyqueue(Que *queue) while(queue- delete queue- node = queue-front;front =
4、 node- delete queue;3.主文件ThePort.cppCTimefstreamstringtypedef struct InFor string num; int hour; int min; int sec; int year; int mon; int day;Infor;int face();int Face();bool Book(Stack *stack,Que *queue,int max);void bookface();time_t compare(Infor *infor);void Display(Infor *infor);time_t arrival(
5、Stack *stack,Infor *infor,Que *queue,int max);void leave(Stack *stack,Que *queue,time_t inform);void Getmoney(Infor *infor,int Bianhao,time_t inform);void checknum(string num);void InforBook(Stack *stack,Que *queue,int max);int Inforface();void Inforstack();void Inforleave();void Inforqueue(Que *que
6、ue);int main() ofstream fout(estdout.txt,ios:trunc); ofstream fout2(leaveout.txt bookface(); fout.close(); fout2.close(); return 0;void bookface() stack = Createstack(); queue = CreateQueue(); int max; bool flag = false; while(max = face() if(max 20 | max = 0) coutttt输入错误,请重新输入!endl; system(pause);c
7、ls else flag = Book(stack,queue,max); if(flag = true) break;int face() coutendlmax; return max;int Face() system(ttt*ttt* *ttt* 1、停车登记 2、离开结算 *ttt* 3、登记记录 4、退出系统 *tt请输入你的业务: int choose;choose; return choose;bool Book(Stack *stack,Que *queue,int max) time_t inform; while(choose = Face() Infor *infor;
8、 infor = new Infor; if(choose 4 | choose switch(choose) case 1: inform = arrival(stack,infor,queue,max); max-; break; case 2: leave(stack,queue,inform); case 3: InforBook(stack,queue,max); case 4: cout 0) inform = compare(infor); push(stack,infor); Display(infor); return inform; couthour = inform-tm
9、_hour;min = inform-tm_min;sec = inform-tm_sec;year = inform-tm_year;mon = inform-tm_mon;day = inform-tm_mday;请输入你的车牌号:infor-num; checknum(infor-num); return now;void Display(Infor *infor)app);ttt车牌号 :numttt当前年月:year+1900/mon+1dayttt当前时刻: hourminsec foutmon+1 count; if(m while(1) checknum(num); for(i
10、nt i=0;im;i+) temp = (Infor *)pop(stack); push(stacktemp,temp); for(int k=0;knumk != numk) flag = false; break; else flag = true; if(flag = true) if(m = 1) Getmoney(temp,m,inform); a = (Infor *)pop(stacktemp); Getmoney(a,i,inform); for(int j=0;jcount a = (Infor *)Dequeue(queue); compare(a); if(flag
11、= false)没有此车的车牌号或车牌号错误,请重新输入: cin for(int n=0;n Z | num0 9 | numi 0 flag = false; if(flag = false)你输入的车牌类型,请重新输入你的车牌号 continue; else void Getmoney(Infor *infor,int Bianhao,time_t inform) struct tm *inform2; inform2 = localtime(& double pay; pay = (difftime(now,inform)*1)/10;tt编号 :Bianhaotm_year+1900tm_mon+1tm_mdaytt当前时刻 :tm_hourtm_mintm_sectt你的需要缴纳的费用:paynumyearmondayhourminsec;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1