Tanguy MAZE f9e508d5ef init
2019-06-22 18:23:35 +02:00

61 lines
1.4 KiB
Plaintext

Assignment name : flood_fill
Expected files : *.c, *.h
Allowed functions: -
--------------------------------------------------------------------------------
Write a function that takes a char ** as a 2-dimensional array of char, a
t_point as the dimensions of this array and a t_point as the starting point.
Starting from the given 'begin' t_point, this function 'colors' an entire zone
by replacing characters inside by the character 'F'. A zone is an ensemble of
the same character delimitated horizontally and vertically by other characters.
The flood_fill function won't 'color' in diagonal.
The flood_fill function will be prototyped like this:
void flood_fill(char **tab, t_point size, t_point begin);
The t_point structure is available inside the "t_point.h" file attached to this
assignment. We will use our "t_point.h" for graduation.
Example :
$> cat test_main.c
#include "test_functions.h"
#include "flood_fill.h"
int main(void)
{
char **area;
t_point size = { 8, 5 };
t_point begin = { 2, 2 };
char *zone[] = {
"11111111",
"10001001",
"10010001",
"10110001",
"11100001"
};
area = make_area(zone);
print_tab(area);
flood_fill(area, size, begin);
putc('\n');
print_tab(area);
return (0);
}
$> gcc flood_fill.c test_main.c test_functions.c -o flood_fill ; ./flood_fill
1 1 1 1 1 1 1 1
1 0 0 0 1 0 0 1
1 0 0 1 0 0 0 1
1 0 1 1 0 0 0 1
1 1 1 0 0 0 0 1
1 1 1 1 1 1 1 1
1 F F F 1 0 0 1
1 F F 1 0 0 0 1
1 F 1 1 0 0 0 1
1 1 1 0 0 0 0 1
$>