今天我在浏览一些 C++ 代码时偶然发现了这一点:
while (c--) {
a = (a + 1) % n;
while(arr[a]) a = (a + 1) % n;
}
c 是一个整数。不要while循环使用布尔表达式进行评估?我知道 1 和 0 很好,因为它们分别代表真和假,但在这种情况下,c 的值不是 0 和 1。这有什么作用?
今天我在浏览一些 C++ 代码时偶然发现了这一点:
while (c--) {
a = (a + 1) % n;
while(arr[a]) a = (a + 1) % n;
}
c 是一个整数。不要while循环使用布尔表达式进行评估?我知道 1 和 0 很好,因为它们分别代表真和假,但在这种情况下,c 的值不是 0 和 1。这有什么作用?