ajout du fichier print qui contient les fonctinos de print de bits
This commit is contained in:
3
fillit.h
3
fillit.h
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/27 21:00:53 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/30 13:25:06 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -46,5 +46,6 @@ int check_tetri_errors(char *tetri);
|
||||
int check_tetri_errors_proxy(char *tetri);
|
||||
void search_map(t_fillist *list);
|
||||
void print_map(unsigned int *tab, int width, int height);
|
||||
void print_bits(unsigned int bits, int size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/28 16:12:31 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/30 13:24:40 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
59
print.c
Normal file
59
print.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* print.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */
|
||||
/* Updated: 2019/04/30 13:25:18 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fillit.h"
|
||||
|
||||
/*
|
||||
** DELETE BEFORE EVAL - TEST FUNCTION
|
||||
** Prints a ligne of size bits
|
||||
*/
|
||||
|
||||
void print_bits(unsigned int bits, int size)
|
||||
{
|
||||
unsigned int mask;
|
||||
|
||||
mask = 1 << (size - 1);
|
||||
while (mask)
|
||||
{
|
||||
(bits & mask) ? write(1, "#", 1) : write(1, ".", 1);
|
||||
write(1, " ", 1);
|
||||
mask >>= 1;
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
** DELETE BEFORE EVAL - TEST FUNCTION
|
||||
** Print a map of height and width
|
||||
*/
|
||||
|
||||
void print_map(unsigned int *tab, int width, int height)
|
||||
{
|
||||
int i;
|
||||
unsigned int mask;
|
||||
|
||||
i = 0;
|
||||
mask = 0;
|
||||
while (i++ < width)
|
||||
mask = (mask >> 1) | ((mask | 1) << 31);
|
||||
i = 0;
|
||||
while (i < width * height)
|
||||
{
|
||||
if (i && !(i % width))
|
||||
ft_putchar('\n');
|
||||
tab[i / 32] & (1 << (31 - i % 32)) ? ft_putchar('#') : ft_putchar('.');
|
||||
ft_putchar(' ');
|
||||
i++;
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
|
||||
44
search_map.c
44
search_map.c
@@ -6,54 +6,12 @@
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */
|
||||
/* Updated: 2019/04/30 12:50:06 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/30 13:25:42 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fillit.h"
|
||||
|
||||
/*
|
||||
** DELETE BEFORE EVAL - TEST FUNCTION
|
||||
** print a int in binary
|
||||
*/
|
||||
|
||||
void print_bits(unsigned int bits, int size)
|
||||
{
|
||||
unsigned int mask;
|
||||
|
||||
mask = 1 << (size - 1);
|
||||
while (mask)
|
||||
{
|
||||
(bits & mask) ? write(1, "#", 1) : write(1, ".", 1);
|
||||
write(1, " ", 1);
|
||||
mask >>= 1;
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
** DELETE BEFORE EVAL - TEST FUNCTION
|
||||
** print a map of height and width
|
||||
*/
|
||||
|
||||
void print_map(unsigned int *tab, int width, int height)
|
||||
{
|
||||
int i;
|
||||
unsigned int mask;
|
||||
|
||||
i = 0;
|
||||
mask = ~0u << (32 - width);
|
||||
while (i < width * height)
|
||||
{
|
||||
if (i && !(i % width))
|
||||
ft_putnbrendl(i); // pour imprimer les tailles du tableaux pour faciliter sa verification
|
||||
tab[i / 32] & (1 << (31 - i % 32)) ? ft_putchar('#') : ft_putchar('.');
|
||||
ft_putchar(' ');
|
||||
i++;
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
** function that look for the first place in the map for a tetri
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user