as shown in the picture, the parking fee is charged per second every day, regardless of holidays.
Note:
- the billing period is 24 hours, and the end of the day at 21 o"clock must be next to the night start time at 21:00
- the variables are daytime start time, daytime end time, night start time, night end time, daytime billing standard N yuan / half hour, night pay per time N yuan / time
- charge for more than 1 millisecond, no free time
for example, if a car is parked from 7: 00 a.m. to 9: 00 the next day, the parking fee: 4 + (21-8) * 8 + 4 + (9-8) * 8
my algorithm is weak. I only think of recursive 8-21-8-21 to see that if the parking end time is greater than the next end point (if the start is 8, the next end point is 21), then the end time takes one end point (21) and calculates the cost within its range. Recursive, until the parking end time is less than a small end point, take the end time, calculate the cost, and stop recursion.
I hope you can give me some comments. I appreciate it.