大佬这样有问题吗?
#include <stdio.h>
float unit_price = 2.3; //单价
int price = 13; //起步价
int min_lc = 3; //最短路程
int max_time = 23; //最晚时间
int min_time = 5; //最早时间
int tax = 1; //燃油附加税
/**
* @param int km 路程公里数
* @param int Time 搭乘时间
*/
float calculate_price(int km,int Time)
{
float pay_price;
km = km <= 3 ? 3 : km;
if(Time >= max_time || Time <= min_time){
unit_price *= 1.2;
}
pay_price = price + (km-min_lc) * unit_price + tax;
return pay_price;
}
int main()
{
float one = calculate_price(12,9);
float two = calculate_price(12,18);
float pay_price = one + two;
printf("小明每天打车的钱是:%f",pay_price);
}