42_C_PISCINE/Rush/Rush01/gen.c

51 lines
1.3 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* gen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/23 09:11:05 by cchauvet #+# #+# */
/* Updated: 2022/07/24 20:00:05 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int *ft_gen_row(int *tab, int size, int seed, int row_number)
{
int i;
i = 1;
tab[0] = seed;
while (i < size)
{
tab[i] = size % (tab[i - 1] + seed + 1);
i++;
}
}
int *ft_gen(int size)
{
int *tab;
int i;
int seed;
tab = malloc(sizeof(*tab) * size * size);
seed = 0;
while (seed < size * size)
{
ft_gen_row(tab, 4, seed, 1);
seed++;
}
return (tab);
}
void ft_putchar(char c)
{
write(1, &c, 1);
}