我有一个关于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)。
我的大脑有点混乱,我知道我缺少一些简单的东西。有人能帮忙吗?