gpt4 book ai didi

c - 在 c 中,如何使 1200/500 = 3

转载 作者:太空宇宙 更新时间:2023-11-04 05:01:56 24 4
gpt4 key购买 nike

在 C 中,如何使 1200/500 = 3。

我正在做家庭作业。

Shipping Calculator: Speedy Shipping company will ship your package based on how much it weighs and how far you are sending the package. They will only ship small packages up to 10 pounds. You need to have a program that will help you determine how much they will charge. The charges are based on each 500 miles shipped. They are not pro-rated, i.e., 600 miles is the same charge as 900 miles.

这是他们给你的表格:

包裹重量------------------------每 500 英里运输费率

2 磅或更少------------------------$1.50

大于 2 但不大于 6--------$3.70

6个以上10个以下--------$5.25

这是一个测试用例。

测试用例数据:

重量:5.6 磅
英里:1200 英里

预期结果:

您的运费是 $11.10


我的答案一直在7.40出来

最佳答案

你是想围观吗?在除法之前,你可以在被除数上加上 499。

(0 + 499)/500 -> 0

(1 + 499)/500 -> 1

(1200 + 499)/500 -> 3

这将四舍五入。

关于c - 在 c 中,如何使 1200/500 = 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11195590/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com