I'm dealing with 2 dimensional arrays and i couldn't figure out how to do this:

for example assume we have a 4x4 matrix, and there is a predefined number k(which is between 0 and 128).well let's declare the array as a[i][j]. for example if the value of a[i][j]>k and if the neigbors of a[i][j]<=k,it will count 1.

but when a[i][j]>k , if one or more of a[i][j]'s neigbors is also bigger than k ,it will also count 1. I mean,for example if a[0][0]>k,a[0][1]>k and a[1][1]>k this whole 3 cell count as 1.

how can i make this?

for example assume we have a 4x4 matrix, and there is a predefined number k(which is between 0 and 128).well let's declare the array as a[i][j]. for example if the value of a[i][j]>k and if the neigbors of a[i][j]<=k,it will count 1.

but when a[i][j]>k , if one or more of a[i][j]'s neigbors is also bigger than k ,it will also count 1. I mean,for example if a[0][0]>k,a[0][1]>k and a[1][1]>k this whole 3 cell count as 1.

how can i make this?