I would like to loop through an 8x8 array (64 values in total) and check if 6 vertically adjacent (i.e. a matrix of 2x3) values are >=30, and then increment a counter.
My code is:
for(int i=0; i<=46; i++){
if((array[i] >= 30) && (array[i+1] >= 30) && (array[i+8] >= 30) && (array[i+9] >= 30) && (array[i+16] >= 30)){
count++; // increment the counter
}
}
My questions is: is there a way I can make this if statement shorter?
Aucun commentaire:
Enregistrer un commentaire