-2
for (i=0;i<3;i++)
{
    if(z == 3)
    {
        z = 0;
    }
    z++;
    if(!(ar[i][z] == 'X') & (z < 3))
    winrow == 0;
}

当我逐行调试程序时,第二个 if 语句被跳过。一切都已初始化,这只是一个片段。有什么理由这样做吗?

4

4 回答 4

3

winrow == 0 is a typo that has no side effect so there's nothing to execute whether or not the if clause is true.

于 2013-03-13T20:44:16.160 回答
1

You're saying:

winrow == 0;

in the body of your if statement. This statement means nothing, it isn't assigned to anything, it doesn't have side affects. The compiler therefore likely (with optimizations on) will just skip it. You may mean to say winrow = 0;, which would assign 0 to winrow.

于 2013-03-13T20:44:55.033 回答
0

The second part of the code doesn't do anything.

winrow == 0

checks if winrow is equal to 0 and that statement goes out of scope as soon you hit the brackets.

于 2013-03-13T20:45:22.057 回答
0

可能你的条件不对。这是你试图得到的吗?

if (ar[i][z] != 'X' && z < 3)
于 2013-03-13T20:43:41.990 回答