某市停车场收费标准为:
小型车:首小时内每15分钟收费:2.5元,首小时后每15分钟收费:3.75
大型车:首小时内每15分钟收费:5元,首小时后每15分钟收费:7.5
夜间收费标准(21:00---7:00)一律执行小型车每两小时1元,大型车每两小时2元
请编写程序,输入车型和进场时间(XXXX-XX-XX XX:XX)以及出场时间,计算停车时间,然后算出应收金额(请注意白天和晚上跨时间段问题,比如早上6.30进场,7.15出场;白天不够15分钟部分按照15分钟计算;夜间不够2小时部分也按2小时计算)。
// To_park_car.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <math.h>
#include <time.h>
const int Bigcar_rule = 5; //day per 15 minutes
const float Smallcar_rule = 2.5; //day per 15 minutes
const float Bigcar_att = 7.5; //past 15 minutes in day
const float Smallcar_att =3.75; //past 15 minutes in day
const int Bigcar_night = 2; //night per an hour
const int Smallcar_night = 1; //night per an hour
const int Per_time = 15; // 15 minutes
//Check input value
bool Compare(int sy,int sm,int sd,int sh,int smi,int ey,int em,int ed,int eh,int emi)
{
if(ey > sy ||(ey>=sy && em> sm) || (ey>=sy && em>= sm && ed>sd) ||(ey>=sy && em>= sm && ed>=sd && eh>sh)||(ey>=sy && em>= sm && ed>=sd && eh>=sh && emi>smi))
{
return true;
}
else return false;
}
/// Generates all month of year
int *GenerateMonth(int year)
{
int *month =new int[13];
month[0] = 0;
month[1] = 31;
if((year%4==0&&year%100!=0)||(year%100==0&&year%400==0))
{
month[2] = 29;
}
else
{
month[2] =28;
}
month[3] = 31;
month[4] = 30;
month[5] = 31;
month[6] = 30;
month[7] = 31;
month[8] = 31;
month[9] = 30;
month[10]= 31;
month[11]= 30;
month[12]= 31;
return month;
}
//Check now of hour or less than target to park car hour
bool CheckHour(int sy,int sm,int sd,int sh,int smi,int ey,int em,int ed,int eh,int emi)
{
int hour = sh;
if(hour >24)
{
hour=1;
sd++;
}
if(hour >=21 || sh<7)
{
if(em>sm || ed>sd || ed>=sd && eh>hour || ed>=sd && eh>=hour && emi>=smi)
{
return true;
}
}
if(ey > sy || ed>sd || ed>=sd && eh>hour+1 || ed>=sd && eh>hour && emi>=smi|| em>sm)
{
return true;
}
return false;
}
//Check now of day or less than target to park car date
bool CheckDay(int yy,int mm,int dd,int hh,