# A recursion array scanner

This is a discussion on A recursion array scanner within the C Programming forums, part of the General Programming Boards category; Hello. I am trying to write a recursive function void check_array(int array1[][M],int row,int col,int array1[row][col]); (it might have to be ...

1. ## A recursion array scanner

Hello.
I am trying to write a recursive function
void check_array(int array1[][M],int row,int col,int array1[row][col]);
(it might have to be an int function in the end)

The object of this function is check what number is in array1[row][col] and to printf how many similar neighbors it has.
for example:
Code:
```4 3 2 3 1
5 3 3 2 2
1 1 3 3 2
1 3 3 2 4
5 5 3 4 4```
if function is called with 2,2 then the number is 3 and it has 9 connected 3's
if function is called with 4,4 then the number is 4 and it has 3 connected 4's (the extra 4 in the array is not adjacent)

Now the catch is I need to do it recursively. Do you have any advice on how to approach the problem? I could use a helper sub-function if need be, I jsut have no idea how to approach this.

Thank you

2. How would you, yourself, personally, do it if you had a pencil?

3. After getting the start sqr's value, you need to recursively get all 8 (or fewer) adjacent sqr's values.

for every value == to your start value, you need to follow them and count up all their adjacent sqr's with equal value.

Sounds very much like recursive flood fill, except instead of filling with a color, you're just counting the sqr's that are equal in value.