这题不知道错哪里,求大神提点

题目总版

@[coder_Jackson](/user/1306363) 哪题
by Lg2307 @ 2024-04-05 13:58:55


说一下题目
by 702star @ 2024-04-05 18:11:42


题目是这样的:周末,格莱尔和爸爸打车到游乐园玩。打车计价方案为:2千米以内起步是6元;超过2千米后按1.8元/千米计价;超过10千米后在1.8元/千米的基础上加价50%。此外,停车等候则按时间计费:每3分钟加收1元(注:不满3分钟不计费)。
by coder_Jackson @ 2024-04-05 23:14:57


``` #include <iostream> #include <iomanip> using namespace std; int main() { int d; // 乘车距离,单位为千米 int w; // 等待时间,单位为分钟 cin >> d >> w; // 读取乘车距离和等待时间 double c = 6.0, e = 6.0, f = 6.0; // 不超2千米时的费用(起步价,e为超过10千米时的费用,f为不超2千米时的费用) if(d <= 2) { if (w >= 0) f += (w / 3) * 1; // 每3分钟计费1元,不满3分钟不计费 cout << fixed << setprecision(2) << f << endl; } // 超过2千米后的费用 if (d <= 10 && d > 2) { c += (d - 2) * 1.8; // 超过2千米的部分按1.8元/千米收费 if (w >= 0) c += (w / 3) * 1; // 每3分钟计费1元,不满3分钟不计费 cout << fixed << setprecision(2) << c << endl; } if (d > 10) { e += (10 - 2) * 1.8; e += (d - 10) * (1.8 * 1.5); if (w >= 0) e += (w / 3) * 1; // 每3分钟计费1元,不满3分钟不计费 cout << fixed << setprecision(2) << e << endl; } return 0; } ``````
by coder_Jackson @ 2024-04-06 00:03:17


|