its a question from a test:

i was asks what what1(arr,6,5) expression will return

??

arr is a 2D array which looks like this:

0 1 1 0 1

0 0 1 0 0

0 0 1 1 1

0 1 0 0 0

1 0 0 1 1

1 0 1 1 0

Code:

int what1(int **arr, int m, int n){
int i, j, tmp, stam=0;
for(i=0; i<m; i++)
for(j=0; j<n; j++){
tmp = what2(arr,i,j,m,n);
if (tmp>stam)
stam = tmp;
}
return stam;
}
int what2 (int **arr, int row, int col, int m, int n){
int i,j,tmp, stam=0;
if (row < 0 || row >= m || col < 0 || col >= n) return 0;
if (arr[row][col] == 0) return 0;
arr[row][col] = 0;
for(i=-1; i<2; i++)
for(j=-1; j<2; j++){
if(!i && !j) continue;
tmp = 1 + what2(arr, row+i, col+j, m, n);
if (tmp > stam) stam = tmp;
}
arr[row][col] = 1;
return stam;
}