【发布时间】:2013-08-08 05:12:08
【问题描述】:
我自己没有方便的编译器来检查这个。
- 版本 1(以下)中的代码在 C C99 中是否有效?它可以编译运行吗?
- 在逻辑上是否等同于版本 2 中的代码?
版本 1:
int a, b, c, d;
... some code to set the above variables ...
if (a != b != c != d)
//Do something
... rest of code ...
版本 2:
int a, b, c, d;
... some code to set the above variables ...
if ((a != b) && (a != c) && (a != d) && (b != c) && (b != d) && (c != d))
//Do something
... rest of code ...
【问题讨论】:
-
如果你在线,有几个 online compilers 可用,至少在 Coliru 和 ideone 中,使用 C99 很简单。