int main() {
int cnt = 5;
while(cnt > 0) {
printf("cnt = %d %s\n", --cnt, (cnt == 0) ? "cnt == 0" : "cnt != 0");
}
return 0;
}
cnt = 4 cnt != 0
cnt = 3 cnt != 0
cnt = 2 cnt != 0
cnt = 1 cnt != 0
cnt = 0 cnt == 0
cnt = 4 cnt != 0
cnt = 3 cnt != 0
cnt = 2 cnt != 0
cnt = 1 cnt != 0
cnt = 0 cnt != 0
我认为当cnt = 1之后--cnt,cnt将有新值0,而测试cnt == 0将为真,但实际结果不是我所期望的,为什么?