是否可以以不使用运算顺序的方式编写 (a*b)+(c*d) ?

发布于 2024-09-24 06:14:55 字数 362 浏览 3 评论 0原文

好吧,warsow 有一些非常优秀的 HUD 代码,除了数学逻辑有点奇怪。

输入:

a*b + c*d

解释为:

((d*c) + b) * a

如您所见,游戏以相反的顺序执行一系列操作,而不考虑操作顺序。括号在 hud 代码中不起作用。它必须是一系列线性操作才能得出最终结果。这可能吗? 我知道最好在 HUD 代码中实现正确的数学运算,但在我看来,这更有趣。

Alright, so warsow has some pretty excellent hud code with the exception that the math logic is a bit screwy.

Input:

a*b + c*d

Interpreted as:

((d*c) + b) * a

As you can see, the game does a series of operations in reverse order without regard to order of operations. Parentheses do not work in the hud code. It must be a linear series of operations to come up with the end result. Is this possible?
I understand that it would be better to implement proper math into the hud code, but this is way more fun imo.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唔猫 2024-10-01 06:14:55
a*b + a/c*d -> ((d*c/a) + b) * a

授予正规代数成立

a*b + a/c*d -> ((d*c/a) + b) * a

granted normal algebra holds

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文