it has loop one inside the other

which calls recursive of itself

many parameters.

its a nightmare to get the output on your own by pen and paper

Code:

#include <stdio.h>
#include <stdlib.h>
int what1(int **arr, int m, int n);
int what2 (int **arr, int row, int col, int m, int n);
int main()
{
int ** arr=(int**)malloc(6*sizeof(int*));
*arr = malloc(5*sizeof(int));
*(arr+1) = malloc(5*sizeof(int));
*(arr+2) = malloc(5*sizeof(int));
*(arr+3) = malloc(5*sizeof(int));
*(arr+4) = malloc(5*sizeof(int));
*(arr+5) = malloc(5*sizeof(int));
arr[0][0]=0;
arr[0][1]=1;
arr[0][2]=1;
arr[0][3]=0;
arr[0][4]=1;
arr[1][0]=0;
arr[1][1]=0;
arr[1][2]=1;
arr[1][3]=0;
arr[1][4]=0;
arr[2][0]=0;
arr[2][1]=0;
arr[2][2]=1;
arr[2][3]=1;
arr[2][4]=1;
arr[3][0]=0;
arr[3][1]=1;
arr[3][2]=0;
arr[3][3]=0;
arr[3][4]=0;
arr[4][0]=1;
arr[4][1]=0;
arr[4][2]=0;
arr[4][3]=1;
arr[4][4]=1;
arr[5][0]=1;
arr[5][1]=0;
arr[5][2]=1;
arr[5][3]=1;
arr[5][4]=0;
what1(arr,6,5) ;
return 0;
}
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;
}