jeudi 29 septembre 2016

condition statement executes when conditions are not met

I can not figure out where the bug is in the condition statement:

xo=130, y0=160, x=180, y=210
for(row = 0; row < 480; row++){
    for(col = 0; col < 640; col++){    
         if((col>xo) && (col<(xo+x)) && (row>=yo) && (row<(yo+y))){//do something;}
    }
}

In my particular situation, I want the if statement to execute only when I am withing the window defined by top left [xo+1,yo] and bottom right [x,y]. However, the statement executes even after col is greater then xo+x. I also tried single & operator but it did not help. Is something wrong with my condition statement?

Aucun commentaire:

Enregistrer un commentaire