【发布时间】:2011-03-07 01:34:06
【问题描述】:
我有一个 c 作业问题,如果有人能帮助我指出正确的方向,我会非常高兴。
如果我在模拟手表上有两个分钟点,例如 t1(55 分钟)和 t2(7 分钟),我需要计算两个点之间的最短步数。
到目前为止,我想出的是这两个等式:
-t1 + t2 + 60 =
-55 + 7 + 60
= 12
t1 - t2 + 60 =
55 - 7 + 60
= 108
12 is lower then 108, therefore 12 steps is the shortest distance.
如果我比较两个结果并使用最低的,这似乎可以正常工作。但是,如果我选择另外两个点,例如让 t1 = 39 和 t2 = 34 并将它们代入等式:
-t1 + t2 + 60 = -39 + 34 + 60 = 55
t1 - t2 + 60 = 39 - 34 + 60 = 35
35 is lower then 55, therefore 35 steps is the shortest distance.
但是,35 不是正确答案。 5 步是最近的距离 (39 - 34 = 5)。
我的大脑有些发麻,我知道我错过了一些简单的东西。有人可以帮忙吗?
【问题讨论】:
-
+1 用于提出明确的问题,并提前透露这是家庭作业。 :)
-
t1 - t2 + 60 = 39 - 34 + 60 = 35不正确:结果应该是65。不过,Edward Z. Yang 还是回答了这个问题。