• v2_566879
    了解作者
  • 15.8KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-23 07:16
    上传日期
借助数据结构中栈和队列实现停车厂中车辆的管理,记录车辆车牌,停车时间和停车位置,出去的时候会根据停车时间计算停车费用
parking.rar
  • parking
  • parking
  • car.c
    1.5KB
  • main.o
    2.9KB
  • car
    7.5KB
  • car.o
    1.6KB
  • car.h
    654B
  • .main.c.swp
    12KB
  • makefile
    140B
  • main.c
    1.9KB
  • main.o
    2.8KB
  • .che.c.swp
    12KB
  • che.o
    1.6KB
  • che.c
    1.7KB
  • che
    7.5KB
  • che.h
    734B
  • makefile
    149B
  • main.c
    2.3KB
内容介绍
#include "che.h" int main() { char state; int num,num1,car_num; int time1,time2,time3,time; int expense; int ret,loc = 0,flag = 0,queue; struct information *p,*q; struct pdui *k; k = (struct pdui *)malloc(sizeof(struct pdui)); p = creat_emptystack(p); //printf("p=%p\n",p); q = creat_emptystack(q); creat_emptyqueue(k);: while(1) { car_num = len_stack(p); printf("car_num = %d\n",car_num); queue = if_emptyqueue(k); //printf("queue = %d\n",queue); if(!queue)//not empty { // printf("hello\n");a if(car_num < N) { num = out_queue(k); printf("please reinput time\n"); scanf("%d",&time1); p = push_stack(p,num,time1); //loc++; loc = len_stack(p); printf("num = %d in parking,loc = %d\n",num,loc); continue; } } // printf("p=%p\n",p); printf("please input state\n"); __fpurge(stdin); scanf("%c",&state); // printf("ret = %d\n",ret); if(state == 'a') { if(car_num == N) { printf("full,please goto biandao\nplease input num\n"); scanf("%d",&num); in_queue(k,num); loc = len_queue(k); printf("num = %d inque,loc = %d\n",num,loc); continue; } printf("please input num,time1\n"); scanf("%d,%d",&num,&time1); p = push_stack(p,num,time1); //printf("p=%p\n",p); loc = len_stack(p); printf("num = %d in chechang,loc = %d\n",num,loc); } else { // printf("p=%p\n",p); if(p == NULL) { printf("there is no car\n"); continue; } printf("please input num,time2\n"); scanf("%d,%d",&num,&time2); if(num == p->num) p = pop_stack(p,&num,&time1); else { while((p != NULL) && (num != p->num)) { p = pop_stack(p,&num1,&time3); q = push_stack(q,num1,time3); } // printf("p=%p\n",p); if(p != NULL) p = pop_stack(p,&num,&time1); else flag = 1; //printf("p=%p,flag=%d\n",p,flag); // printf("1\n"); //printf("time = %d,expense = %d\n",time,expense); while(q != NULL) { // printf("2\n"); q = pop_stack(q,&num1,&time3); p = push_stack(p,num1,time3); } if(flag == 1) { printf("do not find %d\n",num); flag = 0; continue; } } time = time2 - time1; expense = 10 * time; printf("time = %d,expense = %d\n",time,expense); // loc--; } } return 0; }
评论
    相关推荐