init
This commit is contained in:
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++;
|
||||
}
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user