Hello, I have a 2D array of 10x10 and I want to search the surrounding cells of only a 3x3 portion of it at a time. How can I go about totaling up the values of the following nested loop? There should be a 1 or a 0 and if it's a 1 that is found, I want to keep track of it and total them up. Then from there I will apply some more logic depending on the total found. This is just a snippet of the problem area and everything else seems fine, there are no errors in the rest of the code. Thank you!
int row = 0;
int col = 0;
for(int x = row - 1; x < row + 1; x++)
{
for(int y = col - 1; y < col + 1; y++)
{
if(x <= 1)
{
x = 0;
}
if(y <= 1)
{
y = 0;
}
}
}