出租车计价
1 #include<stdio.h> 2 3 int main(void) 4 { 5 double length; 6 int time; 7 double money; 8 9 scanf_s("%lf %d", &length, &time); 10 11 if (length <= 3) 12 { 13 money = 10; 14 } 15 else 16 { 17 if (length <= 10) 18 { 19 money = 10 + (length - 3) * 2; 20 } 21 else 22 { 23 money = 10.0 + (10.0 - 3) * 2.0 + (length - 10) * 3; 24 } 25 } 26 27 money = money + time / 5 * 2.0; 28 29 printf("%d", (int)(money + 0.5)); //四舍五入 30 31 return 0; 32 }