📄 paking_leave.c
字号:
#include<stdio.h>
#define N 10
int leavecar_num = -1; //---------------------------------------------------------
typedef struct{
int number[N];
int time[N];
int top; //-------------------------按参考书则top == -1 为空----。
}paking_car//number为车牌号,time为到达时间,创建该结构的栈(停车场)
typedef struct car_node{//----------------------------------------------------
int number;
struct car_node *next;
}*car_nodeptr//等待车辆的链队的结点,number为车牌号
typedef struct{ ///------------------------------------------------------
car_nodeptr front;
car_nodeprt rear;
}waiting_car//等待车辆的链队
void leave(paking_car * a,paking_car * b){ //个人认为每次leave b都为空。
int leavetime = 0;
int lasttime = 0;
int flag = 0; //for search
//a[]->b[];
if( P_empty(&a) == 1 ) return 0;
//search leavecar_number
if( falg != 1)
if( a->number[top] != leavecar_num )
{
b->top++;
b->number[b->top] = a->number[a->top]; //退车到B
b->time[b->top] = a->time[a->top];
a->top--;
}
else
flag = 1; //找到
//popcar 车离开
scanf("请输入离开时间:%d",&leavetime);//输入离开时间
lasttime = leavetime - a->time[a->top];//计算车辆停留时间,计算价钱
printf("离开车辆为%d\n",leavecar_num);
printf("费用为:%d\n",lasttime * 100);
//leave;//车辆离开
//b[]->a[];
if(b->top != -1)
{
a->number[a->top + 1] = b->number[b->top +1];
a->top++;
b->top--;
}
leavecar_num = -1; //重置leavecar_num
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -