5-14哪位大神会做?求解答
#include<stdio.h> double totalExpense(int distance,int time) { double total=1.0; if(distance <= 3) total=13.0; else { if(time>=23 || time<5) total = 13 + (distance-3)*2.3*1.2; else total = 13 + (distance-3)*2.3; } return total; } int main() { int distance1=12,time1=9,distance2=12,time2=18; double total1=0,total2=0,total=0; total1 = totalExpense(distance1,time1); total2 = totalExpense(distance2,time2); total = total1 + total2; printf("小明每天的打车费用是%f\n",total); }
time应该不能作为变量名吧?那个time是不是时间函数呀?