我在一些脑筋急转弯问题库中遇到过这个问题.
What should be the answer of this?
( (3+1) / 3) * 6
I thought it is 7 but the correct answer is 8.
Run Code Online (Sandbox Code Playgroud)
只有在(3 + 1)*(6/3)时才会发生这种情况.由于表达式中有括号,我怎么能得到8?我试着仔细检查,答案是正确的.
有人可以帮我理解这个吗?
使用整数:
((3 + 1) / 3) * 6
= (4 / 3) * 6
= 1 * 6
= 6
Run Code Online (Sandbox Code Playgroud)
使用浮动:
((3 + 1) / 3) * 6
= (4 / 3) * 6
= (4 / 3) * (6 / 1)
Run Code Online (Sandbox Code Playgroud)
作为一个分数:
= (6 * 4) / (3 * 1)
= 24 / 3
= 8
Run Code Online (Sandbox Code Playgroud)