init
This commit is contained in:
commit
29ed24d567
36
BSQ/Makefile
Normal file
36
BSQ/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/07/30 09:24:04 by nlocusso #+# #+# #
|
||||
# Updated: 2022/08/03 14:43:35 by lflandri ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
SRCS = ft_mapcmp.c ft_is_printable.c ft_contain_only.c ft_write_map.c file_reader.c ft_putstr.c find_square.c standart_entry_reader.c ft_strstr.c ft_tablen.c ft_strndup.c main.c ft_atou.c ft_strlen.c ft_is_digit.c ft_duplicated.c ft_split.c map_reader.c ft_strcat.c
|
||||
|
||||
|
||||
PO = ${SRCS:.c=.o}
|
||||
|
||||
NAME = bsq
|
||||
|
||||
all : ${NAME}
|
||||
|
||||
${NAME}: ${PO}
|
||||
gcc -o ${NAME} -Wall -Wextra -Werror ${PO}
|
||||
|
||||
.c.o : $(PO)
|
||||
gcc -c -Wall -Wextra -Werror $< -o ${<:.c=.o}
|
||||
|
||||
clean :
|
||||
rm -f ${PO}
|
||||
|
||||
fclean : clean
|
||||
rm -f ${NAME}
|
||||
|
||||
re : fclean all
|
||||
|
||||
.PHONY : all clean fclean re
|
56
BSQ/bsq.h
Normal file
56
BSQ/bsq.h
Normal file
@ -0,0 +1,56 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* bsq.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/01 20:56:40 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/03 12:44:34 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef BSQ_H
|
||||
# define BSQ_H
|
||||
# include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
struct s_map {
|
||||
char obstacle;
|
||||
char clear;
|
||||
char full;
|
||||
unsigned int v_len;
|
||||
unsigned int h_len;
|
||||
};
|
||||
typedef struct s_map t_map_property;
|
||||
struct s_square
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int size;
|
||||
};
|
||||
typedef struct s_square t_square;
|
||||
int ft_duplicated(char *str);
|
||||
int ft_is_printable(char *str);
|
||||
void starting_crea_map(char *path, char *str_entry);
|
||||
void read_standart_entry(void);
|
||||
void free_map(char **map);
|
||||
unsigned int ft_atou(char *str);
|
||||
unsigned int ft_mapcmp(t_map_property p1, t_map_property p2);
|
||||
int ft_is_digit(char *str);
|
||||
unsigned int ft_contain_only(char **str, char *charset);
|
||||
unsigned int ft_tablen(char **tab);
|
||||
char **ft_atomap(char *str, t_map_property *property);
|
||||
char *ft_strcat(char *dest, char *src);
|
||||
void write_map(char **map, t_map_property map_p);
|
||||
char **ft_split(char *str, char *sep);
|
||||
char *ft_strndup(char *src, unsigned int n);
|
||||
unsigned int ft_strlen(char *str);
|
||||
int ft_strstr(char *str, char *to_find);
|
||||
char *ft_filereader(char *path);
|
||||
void replace_map(char **map, t_square squarre, t_map_property map_p);
|
||||
t_square point_checker(char **map, t_map_property map_p);
|
||||
#endif
|
62
BSQ/file_reader.c
Normal file
62
BSQ/file_reader.c
Normal file
@ -0,0 +1,62 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* file_reader.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/01 20:55:35 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 14:22:34 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
int ft_filelen(char *path)
|
||||
{
|
||||
int file_descriptor;
|
||||
int letter_readed_counter;
|
||||
char letters_readed[10];
|
||||
int length;
|
||||
|
||||
file_descriptor = open(path, O_RDONLY);
|
||||
if (file_descriptor == -1)
|
||||
return (-1);
|
||||
length = 0;
|
||||
letter_readed_counter = -1;
|
||||
while (letter_readed_counter != 0)
|
||||
{
|
||||
letter_readed_counter = read(file_descriptor, letters_readed, 10);
|
||||
length = length + letter_readed_counter;
|
||||
}
|
||||
if (close(file_descriptor) == -1)
|
||||
return (-1);
|
||||
return (length);
|
||||
}
|
||||
|
||||
char *ft_filereader(char *path)
|
||||
{
|
||||
char *str;
|
||||
int file_descriptor;
|
||||
int length;
|
||||
|
||||
length = ft_filelen(path);
|
||||
if (length < 1)
|
||||
{
|
||||
str = malloc(sizeof(*str));
|
||||
str[0] = 0;
|
||||
return (str);
|
||||
}
|
||||
str = malloc(sizeof(*str) * (length + 1));
|
||||
file_descriptor = open(path, O_RDONLY);
|
||||
if (file_descriptor == -1)
|
||||
{
|
||||
str[0] = 0;
|
||||
return (str);
|
||||
}
|
||||
read(file_descriptor, str, length);
|
||||
str[length - 1] = 0;
|
||||
if (close(file_descriptor) == -1)
|
||||
str[0] = 0;
|
||||
return (str);
|
||||
}
|
BIN
BSQ/file_reader.o
Normal file
BIN
BSQ/file_reader.o
Normal file
Binary file not shown.
159
BSQ/find_square.c
Normal file
159
BSQ/find_square.c
Normal file
@ -0,0 +1,159 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* find_square.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/01 21:09:15 by lflandri #+# #+# */
|
||||
/* Updated: 2022/08/02 18:37:53 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
void init_t_squarre(t_square *square, int x, int y, int size)
|
||||
{
|
||||
(*square).size = size;
|
||||
(*square).x = x;
|
||||
(*square).y = y;
|
||||
}
|
||||
|
||||
t_square find_the_biggest_square(t_square square1, t_square square2)
|
||||
{
|
||||
if (square1.size >= square2.size)
|
||||
return (square1);
|
||||
return (square2);
|
||||
}
|
||||
|
||||
int right_bottom_square_checker(t_square square,
|
||||
unsigned int ind, char **map, t_map_property map_p)
|
||||
{
|
||||
unsigned int ind2;
|
||||
|
||||
ind2 = 0;
|
||||
while (ind2 != ind + 1)
|
||||
{
|
||||
if (map[square.y + ind][square.x + ind2] != map_p.obstacle
|
||||
&& map[square.y + ind2][square.x + ind] != map_p.obstacle)
|
||||
ind2++;
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
t_square left_top_square_checker(t_square square, char **map,
|
||||
t_map_property map_p)
|
||||
{
|
||||
unsigned int ind;
|
||||
|
||||
ind = 0;
|
||||
while (square.x + ind != map_p.h_len && square.y + ind != map_p.v_len
|
||||
&& map[square.y + ind][square.x] != map_p.obstacle
|
||||
&& map[square.y][square.x + ind] != map_p.obstacle)
|
||||
{
|
||||
if (right_bottom_square_checker(square, ind, map, map_p))
|
||||
square.size = ind + 1;
|
||||
else
|
||||
return (square);
|
||||
ind++;
|
||||
}
|
||||
return (square);
|
||||
}
|
||||
|
||||
t_square point_checker(char **map, t_map_property map_p)
|
||||
{
|
||||
t_square big_square;
|
||||
t_square new_square;
|
||||
unsigned int ind_w;
|
||||
unsigned int ind_h;
|
||||
|
||||
ind_h = -1;
|
||||
big_square.size = 0;
|
||||
while (++ind_h != map_p.v_len)
|
||||
{
|
||||
ind_w = -1;
|
||||
while (++ind_w != map_p.h_len)
|
||||
{
|
||||
init_t_squarre(&new_square, ind_w, ind_h, 0);
|
||||
new_square = left_top_square_checker(new_square, map, map_p);
|
||||
big_square = find_the_biggest_square(big_square, new_square);
|
||||
}
|
||||
}
|
||||
return (big_square);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
t_square coucou;
|
||||
|
||||
|
||||
t_map_property map_p;
|
||||
map_p.obstacle = 'o';
|
||||
map_p.clear = '.';
|
||||
map_p.full = 'x';
|
||||
map_p.v_len = 5;
|
||||
map_p.h_len = 5;
|
||||
|
||||
char *map[] =
|
||||
{".o...",
|
||||
"oo..o",
|
||||
"..oo.",
|
||||
".....",
|
||||
"..o.o"};
|
||||
|
||||
|
||||
|
||||
t_map_property map_p;
|
||||
map_p.obstacle = 'o';
|
||||
map_p.clear = '.';
|
||||
map_p.full = 'x';
|
||||
map_p.v_len = 30;
|
||||
map_p.h_len = 30;
|
||||
|
||||
char *map[] =
|
||||
{"o....oo...o.o.o..ooo...o....oo",
|
||||
"...o..oo......oo.o..o......o.o",
|
||||
"ooo........o..o.o..oo......ooo",
|
||||
"o......oo...o....oooo..o....o.",
|
||||
"......oo.........o..o.....o...",
|
||||
".o....o.......o.o.oooo...ooo..",
|
||||
".oo.o.oo.ooo.....oo.ooo.o.o.o.",
|
||||
"oo...o.o...o..o.o..oooo....oo.",
|
||||
"..ooo.oo....o..o.oo..o........",
|
||||
"...o.oooo.....ooo..o........o.",
|
||||
"o............oooo.o.o..oo.o.oo",
|
||||
"o....o...oo....o.o....o.o.....",
|
||||
"..o.o...o...oo..ooo......o....",
|
||||
"o....o.........o...o....oo....",
|
||||
"oo..o.......ooo...o...o.ooo.oo",
|
||||
"o.o.....oo..oo.oo....o.oo.oo.o",
|
||||
".o.o..o.oo.oo..o.oo.oo.o.o.o.o",
|
||||
".o.o.....oo.o.o...o..o.oo....o",
|
||||
"....o..oo..o...oo..o....o.o...",
|
||||
"oo.o............o...o..oo..o..",
|
||||
".........o..o.oo..ooo..o..o..o",
|
||||
"..o.ooooo...o.o...o.oo.o.o.ooo",
|
||||
".o....o...oooo..o......o.o....",
|
||||
"o...ooo.....oo..o....o..ooo..o",
|
||||
".o...oo.o.....o.o.....o......o",
|
||||
"o...oo.........o..o.......o...",
|
||||
"oo.....oo.....o....oo.oo......",
|
||||
".........o......oo.o.oo.o.o.o.",
|
||||
"o.o..o...o.o.....o.oo...oo..o.",
|
||||
"..oo...o.oo.ooo..oo.o.o......o"};
|
||||
|
||||
|
||||
coucou = point_checker(map, map_p);
|
||||
//replace_map(map, coucou, map_p);
|
||||
printf ("%d\n", coucou.x);
|
||||
printf ("%d\n", coucou.y);
|
||||
printf ("%d\n", coucou.size);
|
||||
//write_map(map, map_p);
|
||||
}
|
||||
*/
|
BIN
BSQ/find_square.o
Normal file
BIN
BSQ/find_square.o
Normal file
Binary file not shown.
23
BSQ/ft_atou.c
Normal file
23
BSQ/ft_atou.c
Normal file
@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atou.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 10:37:25 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 10:37:52 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
unsigned int ft_atou(char *str)
|
||||
{
|
||||
int i;
|
||||
unsigned int base;
|
||||
|
||||
i = 0;
|
||||
base = 0;
|
||||
while ('0' <= str[i] && str[i] <= '9')
|
||||
base = base * 10 + (str[i++] - '0');
|
||||
return (base);
|
||||
}
|
BIN
BSQ/ft_atou.o
Normal file
BIN
BSQ/ft_atou.o
Normal file
Binary file not shown.
35
BSQ/ft_contain_only.c
Normal file
35
BSQ/ft_contain_only.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_contain_only.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 11:44:05 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/03 17:55:00 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
unsigned int ft_contain_only(char **lines, char *charset)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
|
||||
k = 0;
|
||||
while (lines[k][0] != 0)
|
||||
{
|
||||
i = 0;
|
||||
while (lines[k][i] != 0)
|
||||
{
|
||||
j = 0;
|
||||
while (charset[j] != lines[k][i] && charset[j] != 0)
|
||||
j++;
|
||||
if (charset[j] == 0)
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return (1);
|
||||
}
|
BIN
BSQ/ft_contain_only.o
Normal file
BIN
BSQ/ft_contain_only.o
Normal file
Binary file not shown.
33
BSQ/ft_duplicated.c
Normal file
33
BSQ/ft_duplicated.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_duplicated.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/03 11:50:50 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/03 12:38:01 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_duplicated(char *str)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = 0;
|
||||
while (str[i + 1] != 0)
|
||||
{
|
||||
j = i + 1;
|
||||
while (str[i] != str[j])
|
||||
{
|
||||
if (str[j] == 0)
|
||||
break ;
|
||||
j++;
|
||||
}
|
||||
if (str[j] != 0)
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
BIN
BSQ/ft_duplicated.o
Normal file
BIN
BSQ/ft_duplicated.o
Normal file
Binary file not shown.
25
BSQ/ft_is_digit.c
Normal file
25
BSQ/ft_is_digit.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_is_digit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 10:41:19 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 18:31:40 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_is_digit(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != 0)
|
||||
{
|
||||
if (!(str[i] >= '0' && str[i] <= '9'))
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
BIN
BSQ/ft_is_digit.o
Normal file
BIN
BSQ/ft_is_digit.o
Normal file
Binary file not shown.
22
BSQ/ft_is_printable.c
Normal file
22
BSQ/ft_is_printable.c
Normal file
@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_is_printable.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/03 12:41:02 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/03 12:44:05 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_is_printable(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
if (!(*str >= 32 && *str <= 126))
|
||||
return (0);
|
||||
str++;
|
||||
}
|
||||
return (1);
|
||||
}
|
BIN
BSQ/ft_is_printable.o
Normal file
BIN
BSQ/ft_is_printable.o
Normal file
Binary file not shown.
28
BSQ/ft_mapcmp.c
Normal file
28
BSQ/ft_mapcmp.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_mapcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 14:38:48 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 16:00:11 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
unsigned int ft_mapcmp(t_map_property p1, t_map_property p2)
|
||||
{
|
||||
if (p1.obstacle != p2.obstacle)
|
||||
return (0);
|
||||
if (p1.clear != p2.clear)
|
||||
return (0);
|
||||
if (p1.full != p2.full)
|
||||
return (0);
|
||||
if (p1.v_len != p2.v_len)
|
||||
return (0);
|
||||
if (p1.h_len != p2.h_len)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
BIN
BSQ/ft_mapcmp.o
Normal file
BIN
BSQ/ft_mapcmp.o
Normal file
Binary file not shown.
19
BSQ/ft_putstr.c
Normal file
19
BSQ/ft_putstr.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/31 08:46:44 by nlauvray #+# #+# */
|
||||
/* Updated: 2022/08/02 18:38:07 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
write(1, str++, 1);
|
||||
}
|
BIN
BSQ/ft_putstr.o
Normal file
BIN
BSQ/ft_putstr.o
Normal file
Binary file not shown.
40
BSQ/ft_split.c
Normal file
40
BSQ/ft_split.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_split.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/31 08:41:20 by nlauvray #+# #+# */
|
||||
/* Updated: 2022/08/03 17:34:23 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
char **ft_split(char *str, char *sep)
|
||||
{
|
||||
char **tab;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
unsigned int k;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
tab = malloc(sizeof(str) * ft_strlen(str));
|
||||
while (str[i] != 0 && ft_strlen(str) > i)
|
||||
{
|
||||
k = i;
|
||||
tab[j] = malloc(sizeof(**tab) * (i - k + ft_strstr(&str[i], sep) + 1));
|
||||
while (i < k + ft_strstr(&str[k], sep))
|
||||
{
|
||||
tab[j][i - k] = str[i];
|
||||
i++;
|
||||
}
|
||||
tab[j][i - k] = '\0';
|
||||
i = k + ft_strstr(&str[k], sep) + ft_strlen(sep);
|
||||
j++;
|
||||
}
|
||||
tab[j] = "";
|
||||
return (tab);
|
||||
}
|
BIN
BSQ/ft_split.o
Normal file
BIN
BSQ/ft_split.o
Normal file
Binary file not shown.
24
BSQ/ft_strcat.c
Normal file
24
BSQ/ft_strcat.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 12:01:12 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 12:05:15 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcat(char *dest, char *src)
|
||||
{
|
||||
while (*dest != 0)
|
||||
dest++;
|
||||
while (*src != 0)
|
||||
{
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
return (dest);
|
||||
}
|
BIN
BSQ/ft_strcat.o
Normal file
BIN
BSQ/ft_strcat.o
Normal file
Binary file not shown.
23
BSQ/ft_strlen.c
Normal file
23
BSQ/ft_strlen.c
Normal file
@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/31 08:47:30 by nlauvray #+# #+# */
|
||||
/* Updated: 2022/08/02 14:29:35 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
unsigned int ft_strlen(char *str)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != 0)
|
||||
i++;
|
||||
return (i);
|
||||
}
|
BIN
BSQ/ft_strlen.o
Normal file
BIN
BSQ/ft_strlen.o
Normal file
Binary file not shown.
29
BSQ/ft_strndup.c
Normal file
29
BSQ/ft_strndup.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strndup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 10:19:17 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 14:24:27 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
char *ft_strndup(char *src, unsigned int n)
|
||||
{
|
||||
char *dest;
|
||||
unsigned int i;
|
||||
|
||||
dest = malloc(sizeof(*src) * (ft_strlen(src) + 1));
|
||||
i = 0;
|
||||
while (src[i] != 0 && i < n - 1)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = 0;
|
||||
return (dest);
|
||||
}
|
BIN
BSQ/ft_strndup.o
Normal file
BIN
BSQ/ft_strndup.o
Normal file
Binary file not shown.
31
BSQ/ft_strstr.c
Normal file
31
BSQ/ft_strstr.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/31 08:35:51 by nlauvray #+# #+# */
|
||||
/* Updated: 2022/07/31 12:37:19 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strstr(char *str, char *to_find)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != 0)
|
||||
{
|
||||
j = 0;
|
||||
while (str[i + j] == to_find[j])
|
||||
{
|
||||
if (to_find[j + 1] == 0)
|
||||
return (i);
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
BIN
BSQ/ft_strstr.o
Normal file
BIN
BSQ/ft_strstr.o
Normal file
Binary file not shown.
21
BSQ/ft_tablen.c
Normal file
21
BSQ/ft_tablen.c
Normal file
@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_tablen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 11:04:59 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 14:30:16 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
unsigned int ft_tablen(char **tab)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (tab[i][0] != 0)
|
||||
i++;
|
||||
return (i);
|
||||
}
|
BIN
BSQ/ft_tablen.o
Normal file
BIN
BSQ/ft_tablen.o
Normal file
Binary file not shown.
44
BSQ/ft_write_map.c
Normal file
44
BSQ/ft_write_map.c
Normal file
@ -0,0 +1,44 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_write_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 11:30:49 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/02 18:40:55 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
void write_map(char **map, t_map_property map_p)
|
||||
{
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
|
||||
y = -1;
|
||||
while (++y != map_p.v_len)
|
||||
{
|
||||
x = -1;
|
||||
while (++x != map_p.h_len)
|
||||
write(1, map[y] + x, 1);
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
void replace_map(char **map, t_square squarre, t_map_property map_p)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
y = squarre.y - 1;
|
||||
while (++y != squarre.size + squarre.y)
|
||||
{
|
||||
x = squarre.x - 1;
|
||||
while (++x != squarre.size + squarre.x)
|
||||
{
|
||||
map[y][x] = map_p.full;
|
||||
}
|
||||
}
|
||||
}
|
BIN
BSQ/ft_write_map.o
Normal file
BIN
BSQ/ft_write_map.o
Normal file
Binary file not shown.
75
BSQ/main.c
Normal file
75
BSQ/main.c
Normal file
@ -0,0 +1,75 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/02 11:24:01 by lflandri #+# #+# */
|
||||
/* Updated: 2022/08/03 14:29:29 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
void free_map(char **map)
|
||||
{
|
||||
char **map_adress;
|
||||
|
||||
map -= 1;
|
||||
map_adress = map;
|
||||
while (**map != 0)
|
||||
{
|
||||
free(*map);
|
||||
map++;
|
||||
}
|
||||
free(map_adress);
|
||||
}
|
||||
|
||||
void starting_crea_map(char *path, char *str)
|
||||
{
|
||||
char **map;
|
||||
t_map_property map_p_tempo;
|
||||
t_map_property *map_p;
|
||||
t_square square;
|
||||
|
||||
map_p = &map_p_tempo;
|
||||
if (str == NULL)
|
||||
str = ft_filereader(path);
|
||||
if (ft_strlen(str) <= 4)
|
||||
{
|
||||
free(str);
|
||||
write(2, "map error\n", 10);
|
||||
return ;
|
||||
}
|
||||
map = ft_atomap(str, map_p);
|
||||
free(str);
|
||||
if (map != NULL)
|
||||
{
|
||||
square = point_checker(map, *map_p);
|
||||
replace_map(map, square, *map_p);
|
||||
write_map(map, *map_p);
|
||||
free_map(map);
|
||||
}
|
||||
else
|
||||
write(2, "map error\n", 10);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int ind;
|
||||
|
||||
if (ac != 1)
|
||||
{
|
||||
ind = 0;
|
||||
while (++ind != ac)
|
||||
{
|
||||
starting_crea_map(av[ind], NULL);
|
||||
if (ind + 1 != ac)
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
read_standart_entry();
|
||||
return (0);
|
||||
}
|
BIN
BSQ/main.o
Normal file
BIN
BSQ/main.o
Normal file
Binary file not shown.
80
BSQ/map_reader.c
Normal file
80
BSQ/map_reader.c
Normal file
@ -0,0 +1,80 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* map_reader.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/01 21:13:40 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/03 17:57:26 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
t_map_property ft_map_error(void)
|
||||
{
|
||||
t_map_property property;
|
||||
|
||||
property.full = 0;
|
||||
property.obstacle = 0;
|
||||
property.clear = 0;
|
||||
property.h_len = 0;
|
||||
property.v_len = 0;
|
||||
return (property);
|
||||
}
|
||||
|
||||
t_map_property property_return_error(char *lines_counter)
|
||||
{
|
||||
free(lines_counter);
|
||||
return (ft_map_error());
|
||||
}
|
||||
|
||||
t_map_property ft_get_map_property(char **lines)
|
||||
{
|
||||
t_map_property property;
|
||||
char *lines_counter;
|
||||
unsigned int i;
|
||||
|
||||
if (!(ft_strlen(lines[0]) >= 4)
|
||||
|| !ft_is_printable(&lines[0][ft_strlen(lines[0]) - 3])
|
||||
|| ft_duplicated(&lines[0][ft_strlen(lines[0]) - 3]))
|
||||
return (ft_map_error());
|
||||
lines_counter = ft_strndup(lines[0], ft_strlen(lines[0]) - 2);
|
||||
if (!ft_is_digit(lines_counter))
|
||||
return (property_return_error(lines_counter));
|
||||
if (ft_tablen(&lines[1]) != ft_atou(lines_counter))
|
||||
return (property_return_error(lines_counter));
|
||||
i = 2;
|
||||
while (ft_strlen(lines[1]) == ft_strlen(lines[i]))
|
||||
i++;
|
||||
if (i != ft_tablen(lines))
|
||||
return (property_return_error(lines_counter));
|
||||
property.full = lines[0][ft_strlen(lines[0]) - 1];
|
||||
property.obstacle = lines[0][ft_strlen(lines[0]) - 2];
|
||||
property.clear = lines[0][ft_strlen(lines[0]) - 3];
|
||||
property.v_len = ft_atou(lines_counter);
|
||||
property.h_len = ft_strlen(lines[1]);
|
||||
free(lines_counter);
|
||||
return (property);
|
||||
}
|
||||
|
||||
char **ft_atomap(char *str, t_map_property *property)
|
||||
{
|
||||
char **lines;
|
||||
|
||||
lines = ft_split(str, "\n");
|
||||
*property = ft_get_map_property(lines);
|
||||
if (ft_mapcmp(*property, ft_map_error()) != 0)
|
||||
{
|
||||
free_map(&lines[1]);
|
||||
return (NULL);
|
||||
}
|
||||
lines[0][ft_strlen(lines[0]) - 1] = 0;
|
||||
if (ft_contain_only(&lines[1], &lines[0][ft_strlen(lines[0]) - 2]) == 0)
|
||||
{
|
||||
free_map(&lines[1]);
|
||||
return (NULL);
|
||||
}
|
||||
return (&lines[1]);
|
||||
}
|
BIN
BSQ/map_reader.o
Normal file
BIN
BSQ/map_reader.o
Normal file
Binary file not shown.
2
BSQ/maps
Normal file
2
BSQ/maps
Normal file
@ -0,0 +1,2 @@
|
||||
1_dp
|
||||
_d____________________________________________________________________________________
|
105
BSQ/standart_entry_reader.c
Normal file
105
BSQ/standart_entry_reader.c
Normal file
@ -0,0 +1,105 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* standart_entry_reader.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lflandri <lflandri@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/03 08:52:24 by lflandri #+# #+# */
|
||||
/* Updated: 2022/08/03 18:08:16 by lflandri ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "bsq.h"
|
||||
|
||||
char *add_to_malloc(char *mal, char *str)
|
||||
{
|
||||
char *new_mal;
|
||||
int ind;
|
||||
|
||||
ind = 0;
|
||||
while (mal[ind])
|
||||
ind++;
|
||||
new_mal = malloc(sizeof(char) * (ind + 2));
|
||||
ind = -1;
|
||||
while (mal[++ind])
|
||||
new_mal[ind] = mal[ind];
|
||||
new_mal[ind] = *str;
|
||||
new_mal[ind + 1] = 0;
|
||||
free(mal);
|
||||
return (new_mal);
|
||||
}
|
||||
|
||||
void read_map_on_entry(char *mal, unsigned int lines_counter)
|
||||
{
|
||||
char str[1];
|
||||
unsigned int count;
|
||||
|
||||
count = 0;
|
||||
if (!lines_counter)
|
||||
{
|
||||
free(mal);
|
||||
write(2, "map error\n", 10);
|
||||
return ;
|
||||
}
|
||||
mal = add_to_malloc(mal, "\n");
|
||||
while (count != lines_counter)
|
||||
{
|
||||
read(STDIN_FILENO, str, 1);
|
||||
if (*str == '\n')
|
||||
count++;
|
||||
mal = add_to_malloc(mal, str);
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
starting_crea_map(NULL, mal);
|
||||
}
|
||||
|
||||
void check_read_map_on_entry(char *mal)
|
||||
{
|
||||
char *lines_counter;
|
||||
|
||||
if (!(ft_strlen(mal) >= 4))
|
||||
{
|
||||
free(mal);
|
||||
write(2, "map error\n", 10);
|
||||
return ;
|
||||
}
|
||||
lines_counter = ft_strndup(mal, ft_strlen(mal) - 2);
|
||||
if (!ft_is_digit(lines_counter))
|
||||
{
|
||||
free(mal);
|
||||
free(lines_counter);
|
||||
write(2, "map error\n", 10);
|
||||
return ;
|
||||
}
|
||||
read_map_on_entry(mal, ft_atou(lines_counter));
|
||||
free(lines_counter);
|
||||
}
|
||||
|
||||
void read_standart_entry(void)
|
||||
{
|
||||
char str[1];
|
||||
char *mal;
|
||||
int size;
|
||||
int fd;
|
||||
|
||||
mal = malloc(sizeof(char));
|
||||
*mal = '\0';
|
||||
size = 1;
|
||||
while (size == 1)
|
||||
{
|
||||
size = read(STDIN_FILENO, str, 1);
|
||||
if (*str == '\n')
|
||||
break ;
|
||||
mal = add_to_malloc(mal, str);
|
||||
}
|
||||
fd = open(mal, O_RDONLY);
|
||||
if (fd != -1)
|
||||
{
|
||||
close(fd);
|
||||
starting_crea_map(mal, NULL);
|
||||
free(mal);
|
||||
}
|
||||
else
|
||||
check_read_map_on_entry(mal);
|
||||
}
|
BIN
BSQ/standart_entry_reader.o
Normal file
BIN
BSQ/standart_entry_reader.o
Normal file
Binary file not shown.
18
C/c00/ex00/ft_putchar.c
Normal file
18
C/c00/ex00/ft_putchar.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putchar.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:47:36 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:39:47 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
25
C/c00/ex01/ft_print_alphabet.c
Normal file
25
C/c00/ex01/ft_print_alphabet.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:49:41 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:42:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'a';
|
||||
while ('z' >= a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a++;
|
||||
}
|
||||
}
|
BIN
C/c00/ex02/.ft_print_reverse_alphabet.c.swp
Normal file
BIN
C/c00/ex02/.ft_print_reverse_alphabet.c.swp
Normal file
Binary file not shown.
23
C/c00/ex02/ft_print_reverse_alphabet.c
Normal file
23
C/c00/ex02/ft_print_reverse_alphabet.c
Normal file
@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_reverse_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:52:57 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 13:54:25 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'z';
|
||||
while (a >= 'a')
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a--;
|
||||
}
|
||||
}
|
25
C/c00/ex03/ft_print_numbers.c
Normal file
25
C/c00/ex03/ft_print_numbers.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_numbers.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:55:25 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:45:15 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_numbers(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = '0';
|
||||
while ('9' >= a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a++;
|
||||
}
|
||||
}
|
25
C/c00/ex04/ft_is_negative.c
Normal file
25
C/c00/ex04/ft_is_negative.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_is_negative.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 14:14:39 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:51:31 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_is_negative(int n)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'N';
|
||||
if (n > 0)
|
||||
{
|
||||
a = 'P';
|
||||
}
|
||||
write(1, &a, 1);
|
||||
}
|
54
C/c00/ex05/ft_print_comb.c
Normal file
54
C/c00/ex05/ft_print_comb.c
Normal file
@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_comb.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 14:18:48 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 15:10:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_result(char x, char y, char z)
|
||||
{
|
||||
ft_putchar(x);
|
||||
ft_putchar(y);
|
||||
ft_putchar(z);
|
||||
if (!((x == '7') && (y == '8') && (z == '9')))
|
||||
{
|
||||
ft_putchar(',');
|
||||
ft_putchar(' ');
|
||||
}
|
||||
}
|
||||
|
||||
void ft_print_comb(void)
|
||||
{
|
||||
char x;
|
||||
char y;
|
||||
char z;
|
||||
|
||||
x = '0';
|
||||
while (x <= '7')
|
||||
{
|
||||
y = x + 1;
|
||||
while (y <= '8')
|
||||
{
|
||||
z = y + 1;
|
||||
while (z <= '9')
|
||||
{
|
||||
ft_result(x, y, z);
|
||||
z++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
81
C/c00/ex06/ft_print_comb2.c
Normal file
81
C/c00/ex06/ft_print_comb2.c
Normal file
@ -0,0 +1,81 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_comb2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:08:46 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:25:34 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
bool ft_sames(char a, char b, char c, char d)
|
||||
{
|
||||
char e;
|
||||
|
||||
b = a;
|
||||
if (e != b)
|
||||
return (false);
|
||||
e = b;
|
||||
if (e != c)
|
||||
return (false);
|
||||
e = c;
|
||||
if (e != d)
|
||||
return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
void ft_result(char a, char b, char c, char d)
|
||||
{
|
||||
if (!ft_sames(a, b, c, d))
|
||||
{
|
||||
ft_putchar(a);
|
||||
ft_putchar(b);
|
||||
ft_putchar(' ');
|
||||
ft_putchar(c);
|
||||
ft_putchar(d);
|
||||
if (!((a == '9') && (b == '8') && (c == '9') && (d == '9')))
|
||||
{
|
||||
ft_putchar(',');
|
||||
ft_putchar(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ft_print_comb2(void)
|
||||
{
|
||||
char a;
|
||||
char b;
|
||||
char c;
|
||||
char d;
|
||||
|
||||
a = '0';
|
||||
while (a <= '9')
|
||||
{
|
||||
b = '0';
|
||||
while (b <= '8')
|
||||
{
|
||||
c = '0';
|
||||
while (c <= '9')
|
||||
{
|
||||
d = '0';
|
||||
while (d <= '9')
|
||||
{
|
||||
ft_result(a, b, c, d++);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
b++;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
}
|
36
C/c00/ex07/ft_putnbr.c
Normal file
36
C/c00/ex07/ft_putnbr.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 16:46:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 16:52:22 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(-nb);
|
||||
}
|
||||
else if (nb > 10)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putchar(nb % 10 + 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putchar(nb + 48);
|
||||
}
|
||||
}
|
4
C/c00/ex08/ft_print_combn.c
Normal file
4
C/c00/ex08/ft_print_combn.c
Normal file
@ -0,0 +1,4 @@
|
||||
void ft_print_combn(int n)
|
||||
{
|
||||
|
||||
}
|
18
C/c00v2/ex00/ft_putchar.c
Normal file
18
C/c00v2/ex00/ft_putchar.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putchar.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:47:36 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:39:47 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
25
C/c00v2/ex01/ft_print_alphabet.c
Normal file
25
C/c00v2/ex01/ft_print_alphabet.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:49:41 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:42:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'a';
|
||||
while ('z' >= a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a++;
|
||||
}
|
||||
}
|
25
C/c00v2/ex02/ft_print_reverse_alphabet.c
Normal file
25
C/c00v2/ex02/ft_print_reverse_alphabet.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_reverse_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:52:57 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/16 10:37:57 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'z';
|
||||
while (a >= 'a')
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a--;
|
||||
}
|
||||
}
|
25
C/c00v2/ex03/ft_print_numbers.c
Normal file
25
C/c00v2/ex03/ft_print_numbers.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_numbers.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:55:25 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:45:15 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_numbers(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = '0';
|
||||
while ('9' >= a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a++;
|
||||
}
|
||||
}
|
25
C/c00v2/ex04/ft_is_negative.c
Normal file
25
C/c00v2/ex04/ft_is_negative.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_is_negative.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 14:14:39 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/16 10:38:55 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_is_negative(int n)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'N';
|
||||
if (n >= 0)
|
||||
{
|
||||
a = 'P';
|
||||
}
|
||||
write(1, &a, 1);
|
||||
}
|
54
C/c00v2/ex05/ft_print_comb.c
Normal file
54
C/c00v2/ex05/ft_print_comb.c
Normal file
@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_comb.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 14:18:48 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 15:10:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_result(char x, char y, char z)
|
||||
{
|
||||
ft_putchar(x);
|
||||
ft_putchar(y);
|
||||
ft_putchar(z);
|
||||
if (!((x == '7') && (y == '8') && (z == '9')))
|
||||
{
|
||||
ft_putchar(',');
|
||||
ft_putchar(' ');
|
||||
}
|
||||
}
|
||||
|
||||
void ft_print_comb(void)
|
||||
{
|
||||
char x;
|
||||
char y;
|
||||
char z;
|
||||
|
||||
x = '0';
|
||||
while (x <= '7')
|
||||
{
|
||||
y = x + 1;
|
||||
while (y <= '8')
|
||||
{
|
||||
z = y + 1;
|
||||
while (z <= '9')
|
||||
{
|
||||
ft_result(x, y, z);
|
||||
z++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
36
C/c00v2/ex07/ft_putnbr.c
Normal file
36
C/c00v2/ex07/ft_putnbr.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 16:46:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 16:52:22 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(-nb);
|
||||
}
|
||||
else if (nb > 10)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putchar(nb % 10 + 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putchar(nb + 48);
|
||||
}
|
||||
}
|
18
C/c00v3/ex00/ft_putchar.c
Normal file
18
C/c00v3/ex00/ft_putchar.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putchar.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:47:36 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:39:47 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
25
C/c00v3/ex01/ft_print_alphabet.c
Normal file
25
C/c00v3/ex01/ft_print_alphabet.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:49:41 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:42:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'a';
|
||||
while ('z' >= a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a++;
|
||||
}
|
||||
}
|
25
C/c00v3/ex02/ft_print_reverse_alphabet.c
Normal file
25
C/c00v3/ex02/ft_print_reverse_alphabet.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_reverse_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:52:57 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/17 13:07:32 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_reverse_alphabet(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'z';
|
||||
while (a >= 'a')
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a--;
|
||||
}
|
||||
}
|
25
C/c00v3/ex03/ft_print_numbers.c
Normal file
25
C/c00v3/ex03/ft_print_numbers.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_numbers.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 13:55:25 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 14:45:15 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_numbers(void)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = '0';
|
||||
while ('9' >= a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
a++;
|
||||
}
|
||||
}
|
25
C/c00v3/ex04/ft_is_negative.c
Normal file
25
C/c00v3/ex04/ft_is_negative.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_is_negative.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 14:14:39 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/16 10:38:55 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_is_negative(int n)
|
||||
{
|
||||
char a;
|
||||
|
||||
a = 'N';
|
||||
if (n >= 0)
|
||||
{
|
||||
a = 'P';
|
||||
}
|
||||
write(1, &a, 1);
|
||||
}
|
54
C/c00v3/ex05/ft_print_comb.c
Normal file
54
C/c00v3/ex05/ft_print_comb.c
Normal file
@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_comb.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 14:18:48 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 15:10:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_result(char x, char y, char z)
|
||||
{
|
||||
ft_putchar(x);
|
||||
ft_putchar(y);
|
||||
ft_putchar(z);
|
||||
if (!((x == '7') && (y == '8') && (z == '9')))
|
||||
{
|
||||
ft_putchar(',');
|
||||
ft_putchar(' ');
|
||||
}
|
||||
}
|
||||
|
||||
void ft_print_comb(void)
|
||||
{
|
||||
char x;
|
||||
char y;
|
||||
char z;
|
||||
|
||||
x = '0';
|
||||
while (x <= '7')
|
||||
{
|
||||
y = x + 1;
|
||||
while (y <= '8')
|
||||
{
|
||||
z = y + 1;
|
||||
while (z <= '9')
|
||||
{
|
||||
ft_result(x, y, z);
|
||||
z++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
36
C/c00v3/ex07/ft_putnbr.c
Normal file
36
C/c00v3/ex07/ft_putnbr.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 16:46:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 16:52:22 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char a)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(-nb);
|
||||
}
|
||||
else if (nb > 10)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putchar(nb % 10 + 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putchar(nb + 48);
|
||||
}
|
||||
}
|
18
C/c01/ex00/ft_ft.c
Normal file
18
C/c01/ex00/ft_ft.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 15:22:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:33:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_ft(int *nbr)
|
||||
{
|
||||
*nbr = 42;
|
||||
}
|
16
C/c01/ex01/ft_ultimate_ft.c
Normal file
16
C/c01/ex01/ft_ultimate_ft.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:27:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:53:31 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_ultimate_ft(int *********nbr)
|
||||
{
|
||||
*********nbr = 42;
|
||||
}
|
20
C/c01/ex02/ft_swap.c
Normal file
20
C/c01/ex02/ft_swap.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_swap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:46:50 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:51:16 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
17
C/c01/ex03/ft_div_mod.c
Normal file
17
C/c01/ex03/ft_div_mod.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_div_mod.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:58:15 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:58:24 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_div_mod(int a, int b, int *div, int *mod)
|
||||
{
|
||||
*div = a/b;
|
||||
*mod = a%b;
|
||||
}
|
20
C/c01/ex04/ft_ultimate_div_mod.c
Normal file
20
C/c01/ex04/ft_ultimate_div_mod.c
Normal file
@ -0,0 +1,20 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
/* ft_ultimate_div_mod.c :+: :+: :+: */
|
||||
# +:+ +:+ +:+ #
|
||||
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/07/14 18:58:45 by cchauvet #+# #+# #
|
||||
/* Updated: 2022/07/14 19:03:57 by cchauvet ### ########.fr */
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
void ft_ultimate_div_mod(int *a, int *b)
|
||||
{
|
||||
int c;
|
||||
int d;
|
||||
|
||||
c = *a/*b;
|
||||
d = *a%*b;
|
||||
}
|
20
C/c01/ex05/ft_putstr.c
Normal file
20
C/c01/ex05/ft_putstr.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 19:18:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
write(1, str++, 1);
|
||||
}
|
||||
}
|
25
C/c01/ex06/ft_strlen.c
Normal file
25
C/c01/ex06/ft_strlen.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 12:03:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
int ft_strlen(char *str)
|
||||
{
|
||||
int a;
|
||||
|
||||
a = 0;
|
||||
while (*str != 0)
|
||||
{
|
||||
a++;
|
||||
str++;
|
||||
}
|
||||
return(a);
|
||||
}
|
32
C/c01/ex07/ft_rev_int_tab.c
Normal file
32
C/c01/ex07/ft_rev_int_tab.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_rev_int_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/15 09:31:51 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:54:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
||||
|
||||
void ft_rev_int_tab(int *tab, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < size / 2)
|
||||
{
|
||||
ft_swap(tab + i, tab + size - i - 1);
|
||||
i++;
|
||||
}
|
||||
}
|
18
C/c01v1/ex00/ft_ft.c
Normal file
18
C/c01v1/ex00/ft_ft.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 15:22:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:33:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_ft(int *nbr)
|
||||
{
|
||||
*nbr = 42;
|
||||
}
|
16
C/c01v1/ex01/ft_ultimate_ft.c
Normal file
16
C/c01v1/ex01/ft_ultimate_ft.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:27:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:53:31 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_ultimate_ft(int *********nbr)
|
||||
{
|
||||
*********nbr = 42;
|
||||
}
|
20
C/c01v1/ex02/ft_swap.c
Normal file
20
C/c01v1/ex02/ft_swap.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_swap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:46:50 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:51:16 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
17
C/c01v1/ex03/ft_div_mod.c
Normal file
17
C/c01v1/ex03/ft_div_mod.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_div_mod.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:58:15 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:58:24 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_div_mod(int a, int b, int *div, int *mod)
|
||||
{
|
||||
*div = a/b;
|
||||
*mod = a%b;
|
||||
}
|
20
C/c01v1/ex04/ft_ultimate_div_mod.c
Normal file
20
C/c01v1/ex04/ft_ultimate_div_mod.c
Normal file
@ -0,0 +1,20 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
/* ft_ultimate_div_mod.c :+: :+: :+: */
|
||||
# +:+ +:+ +:+ #
|
||||
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/07/14 18:58:45 by cchauvet #+# #+# #
|
||||
/* Updated: 2022/07/14 19:03:57 by cchauvet ### ########.fr */
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
void ft_ultimate_div_mod(int *a, int *b)
|
||||
{
|
||||
int c;
|
||||
int d;
|
||||
|
||||
c = *a/*b;
|
||||
d = *a%*b;
|
||||
}
|
20
C/c01v1/ex05/ft_putstr.c
Normal file
20
C/c01v1/ex05/ft_putstr.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 19:18:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
write(1, str++, 1);
|
||||
}
|
||||
}
|
25
C/c01v1/ex06/ft_strlen.c
Normal file
25
C/c01v1/ex06/ft_strlen.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 12:03:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
int ft_strlen(char *str)
|
||||
{
|
||||
int a;
|
||||
|
||||
a = 0;
|
||||
while (*str != 0)
|
||||
{
|
||||
a++;
|
||||
str++;
|
||||
}
|
||||
return(a);
|
||||
}
|
32
C/c01v1/ex07/ft_rev_int_tab.c
Normal file
32
C/c01v1/ex07/ft_rev_int_tab.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_rev_int_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/15 09:31:51 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:54:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
||||
|
||||
void ft_rev_int_tab(int *tab, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < size / 2)
|
||||
{
|
||||
ft_swap(tab + i, tab + size - i - 1);
|
||||
i++;
|
||||
}
|
||||
}
|
18
C/c01v2/ex00/ft_ft.c
Normal file
18
C/c01v2/ex00/ft_ft.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 15:22:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:33:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_ft(int *nbr)
|
||||
{
|
||||
*nbr = 42;
|
||||
}
|
16
C/c01v2/ex01/ft_ultimate_ft.c
Normal file
16
C/c01v2/ex01/ft_ultimate_ft.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:27:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:53:31 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_ultimate_ft(int *********nbr)
|
||||
{
|
||||
*********nbr = 42;
|
||||
}
|
20
C/c01v2/ex02/ft_swap.c
Normal file
20
C/c01v2/ex02/ft_swap.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_swap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:46:50 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:51:16 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
17
C/c01v2/ex03/ft_div_mod.c
Normal file
17
C/c01v2/ex03/ft_div_mod.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_div_mod.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:58:15 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/18 10:35:36 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_div_mod(int a, int b, int *div, int *mod)
|
||||
{
|
||||
*div = a / b;
|
||||
*mod = a % b;
|
||||
}
|
20
C/c01v2/ex04/ft_ultimate_div_mod.c
Normal file
20
C/c01v2/ex04/ft_ultimate_div_mod.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_div_mod.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:37:49 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/18 10:38:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_ultimate_div_mod(int *a, int *b)
|
||||
{
|
||||
int c;
|
||||
int d;
|
||||
|
||||
c = *a / *b;
|
||||
d = *a % *b;
|
||||
}
|
20
C/c01v2/ex05/ft_putstr.c
Normal file
20
C/c01v2/ex05/ft_putstr.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 19:18:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
write(1, str++, 1);
|
||||
}
|
||||
}
|
25
C/c01v2/ex06/ft_strlen.c
Normal file
25
C/c01v2/ex06/ft_strlen.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/18 10:34:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
int ft_strlen(char *str)
|
||||
{
|
||||
int a;
|
||||
|
||||
a = 0;
|
||||
while (*str != 0)
|
||||
{
|
||||
a++;
|
||||
str++;
|
||||
}
|
||||
return (a);
|
||||
}
|
32
C/c01v2/ex07/ft_rev_int_tab.c
Normal file
32
C/c01v2/ex07/ft_rev_int_tab.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_rev_int_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/15 09:31:51 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:54:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
||||
|
||||
void ft_rev_int_tab(int *tab, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < size / 2)
|
||||
{
|
||||
ft_swap(tab + i, tab + size - i - 1);
|
||||
i++;
|
||||
}
|
||||
}
|
18
C/c01v3/ex00/ft_ft.c
Normal file
18
C/c01v3/ex00/ft_ft.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 15:22:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:33:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_ft(int *nbr)
|
||||
{
|
||||
*nbr = 42;
|
||||
}
|
16
C/c01v3/ex01/ft_ultimate_ft.c
Normal file
16
C/c01v3/ex01/ft_ultimate_ft.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_ft.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:27:16 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 18:53:31 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_ultimate_ft(int *********nbr)
|
||||
{
|
||||
*********nbr = 42;
|
||||
}
|
20
C/c01v3/ex02/ft_swap.c
Normal file
20
C/c01v3/ex02/ft_swap.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_swap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:46:50 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:51:16 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
17
C/c01v3/ex03/ft_div_mod.c
Normal file
17
C/c01v3/ex03/ft_div_mod.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_div_mod.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 18:58:15 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/18 10:35:36 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_div_mod(int a, int b, int *div, int *mod)
|
||||
{
|
||||
*div = a / b;
|
||||
*mod = a % b;
|
||||
}
|
22
C/c01v3/ex04/ft_ultimate_div_mod.c
Normal file
22
C/c01v3/ex04/ft_ultimate_div_mod.c
Normal file
@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_div_mod.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:37:49 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 19:06:46 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_ultimate_div_mod(int *a, int *b)
|
||||
{
|
||||
int c;
|
||||
int d;
|
||||
|
||||
c = *a / *b;
|
||||
d = *a % *b;
|
||||
*a = c;
|
||||
*b = d;
|
||||
}
|
20
C/c01v3/ex05/ft_putstr.c
Normal file
20
C/c01v3/ex05/ft_putstr.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/14 19:18:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
write(1, str++, 1);
|
||||
}
|
||||
}
|
24
C/c01v3/ex06/ft_strlen.c
Normal file
24
C/c01v3/ex06/ft_strlen.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/14 19:06:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/18 10:34:56 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strlen(char *str)
|
||||
{
|
||||
int a;
|
||||
|
||||
a = 0;
|
||||
while (*str != 0)
|
||||
{
|
||||
a++;
|
||||
str++;
|
||||
}
|
||||
return (a);
|
||||
}
|
32
C/c01v3/ex07/ft_rev_int_tab.c
Normal file
32
C/c01v3/ex07/ft_rev_int_tab.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_rev_int_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/15 09:31:51 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/15 10:54:35 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_swap(int *a, int *b)
|
||||
{
|
||||
int tempo;
|
||||
|
||||
tempo = *a;
|
||||
*a = *b;
|
||||
*b = tempo;
|
||||
}
|
||||
|
||||
void ft_rev_int_tab(int *tab, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < size / 2)
|
||||
{
|
||||
ft_swap(tab + i, tab + size - i - 1);
|
||||
i++;
|
||||
}
|
||||
}
|
52
C/c01v3/ex08/ft_sort_int_tab.c
Normal file
52
C/c01v3/ex08/ft_sort_int_tab.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_sort_int_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 19:08:01 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 20:49:46 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void ft_sort_int_tab(int *tab, int size)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int tempo;
|
||||
|
||||
i = 0;
|
||||
while (i < size)
|
||||
{
|
||||
j = 0;
|
||||
while (j < size - 1)
|
||||
{
|
||||
if (tab[j] > tab[j + 1])
|
||||
{
|
||||
tempo = tab[j];
|
||||
tab[j] = tab[j + 1];
|
||||
tab[j + 1] = tempo;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
int tab[] = {6,5,4,3,2,1};
|
||||
int i = 0;
|
||||
|
||||
ft_sort_int_tab(tab, 6);
|
||||
while (i < 6)
|
||||
{
|
||||
printf("%d,", tab[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
*/
|
49
C/c02/ex00/ft_strcpy.c
Normal file
49
C/c02/ex00/ft_strcpy.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 12:53:54 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcpy(char *dest, char *src)
|
||||
{
|
||||
while (*src != '\0')
|
||||
{
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
*dest = '\0';
|
||||
return (dest);
|
||||
}
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char dest1[10];
|
||||
char src1[10] = "test";
|
||||
|
||||
strcpy(dest1, src1);
|
||||
|
||||
printf("%s", dest1);
|
||||
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
||||
char dest2[10];
|
||||
char src2[10] = "test";
|
||||
|
||||
ft_strcpy(dest2, src2);
|
||||
|
||||
printf("%s", dest2);
|
||||
}
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user