init
This commit is contained in:
60
exam-basedir03/subjects/flood_fill/subject.en.txt
Normal file
60
exam-basedir03/subjects/flood_fill/subject.en.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
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
|
||||
$>
|
62
exam-basedir03/subjects/flood_fill/subject.fr.txt
Normal file
62
exam-basedir03/subjects/flood_fill/subject.fr.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
Assignment name : flood_fill
|
||||
Expected files : *.c, *.h
|
||||
Allowed functions: -
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Ecrivez une fonction qui prends en paramètres un char** qui sera une aire à 2
|
||||
dimensions, une structure de type t_point qui donnera la longueur et la largeur
|
||||
de cette aire, et une structure de type t_point symbolisant le point de départ.
|
||||
|
||||
Cette fonction devra 'colorer' une zone de l'aire donnée en argument, en
|
||||
remplaçant les caractères de cette zone par des 'F'. Une zone est un ensemble
|
||||
de mêmes caractères, délimitée horizontalement et verticalement par d'autres
|
||||
caractères.
|
||||
|
||||
La fonction flood_fill ne 'colore' pas en diagonale.
|
||||
|
||||
La fonction flood_fill devra être prototypée comme suit :
|
||||
void flood_fill(char **tab, t_point size, t_point begin);
|
||||
|
||||
La structure t_point est présente dans le fichier "t_point.h" mis en annexe
|
||||
de ce sujet. Nous utiliserons notre "t_point.h" pour le rendu.
|
||||
|
||||
Exemple:
|
||||
|
||||
$>cat test_main.c
|
||||
#include "test_functions.h"
|
||||
#include "t_point.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
|
||||
$>
|
10
exam-basedir03/subjects/flood_fill/t_point.h
Normal file
10
exam-basedir03/subjects/flood_fill/t_point.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef T_POINT_FLOOD_FILL
|
||||
# define T_POINT_FLOOD_FILL
|
||||
|
||||
typedef struct s_point {
|
||||
int x; // x : Width | x-axis
|
||||
int y; // y : Height | y-axis
|
||||
} t_point;
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user