1 solutions
-
0
C :
#include "stdio.h" #include "math.h" int main() { float dis; int minute; float price = 0; scanf("%f,%d", &dis, &minute); // 按照规则计算里程费用 if (dis <= 3) { price = 8; } else if (dis <= 10) { price = 8 + (dis - 3) * 2; } else { price = 8 + 7 * 2 + (dis - 10) * 3; } // 不足五分钟不计分,即只计算五的倍数 int time = minute / 5; price = price + 2*time; // 计算四舍五入 float t = price - (int)price; if (t >= 0.5) { price = (int) price + 1; } else { price = (int) price; } // 输出价格 printf("fee = %.0f\n", price); return 0; }
- 1
Information
- ID
- 90
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By