-
IF statement
I always seem to have trouble getting the right balance on if statements which contain AND's and OR's.
whats wrong with this
IF (Env[j] == 1 && POPinit[i][j] == 1 || Env[j] == 1 && POPinit[i][j] == 4)
basically TRUE when Env = 1 and POPinit is a 1 or 4 aswell.
But it doesn't seem to work at all any ideas?
-
should add parentheses
Kuphryn
-
-
Why not:
Code:
if(Env[j] == 1 && (POPinit[i][j] == 1 || POPinit[i][j] == 4))
Checking Env[j] twice is unnecessary.
-
thanks, just realised there may have been a problem earlier on the code.
int Env[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0];
does this actually create an array Env[180] filled with the above? i'am guessing now it doesn't.
-
Heh...just guessing, but it looks like you're declaring a 0-length array there. The comma operator ignores the lho and returns the rho.
-
You want: int Env[180] = { 0, 0, 1, ......... };
-