I wrote this to perform floodfill and here are two issues:
1-i need to get length
from user,how can I pass an array with unknown length to a function?
2-should I change arguments which recall floodfill inside the function?
#include <stdio.h>
int main() {
const int length = 9;
int board[length][length],sheet[length][length];
int i=1,j=1;
floodfill(board,sheet,i,j);
return 0;
}
void floodfill(int board[length][length],int sheet[length][length], int i,int j){
if(board[i][j]!=-1)
{
sheet[i][j]= 1;
if(i-1>0 && j>0)
floodfill(board, sheet, i-1,j);
if(i+1>0 && j>0)
floodfill(board, sheet, i+1,j);
if(i>0 && j+1>0)
floodfill(board, sheet, i,j+1);
if(i>0 && j-1>0)
floodfill(board, sheet, i,j-1);
}
}