0
0

Add all git folders

This commit is contained in:
Baco
2021-08-15 23:30:40 +02:00
parent 0abd1f86bc
commit a808b91a50
123 changed files with 2391 additions and 0 deletions

2
C_Piscine_C_00/git/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
**/main.c
**/main.sh

View File

@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 13:11:26 by gbaconni #+# #+# */
/* Updated: 2021/08/06 09:21:17 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}

View File

@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_alphabet.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 13:11:54 by gbaconni #+# #+# */
/* Updated: 2021/08/05 13:17:19 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_alphabet(void)
{
int start;
int end;
int i;
start = (int) 'a';
end = (int) 'z';
i = start;
while (i <= end)
{
write(1, &i, 1);
i++;
}
}

View File

@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_reverse_alphabet.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 13:13:58 by gbaconni #+# #+# */
/* Updated: 2021/08/05 13:17:00 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_reverse_alphabet(void)
{
int start;
int end;
int i;
start = (int) 'z';
end = (int) 'a';
i = start;
while (i >= end)
{
write(1, &i, 1);
i--;
}
}

View File

@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_numbers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 13:15:47 by gbaconni #+# #+# */
/* Updated: 2021/08/05 13:16:35 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_numbers(void)
{
int start;
int end;
int i;
start = (int) '0';
end = (int) '9';
i = start;
while (i <= end)
{
write(1, &i, 1);
i++;
}
}

View File

@@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_negative.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 13:18:29 by gbaconni #+# #+# */
/* Updated: 2021/08/05 13:45:21 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_is_negative(int n)
{
char c;
if (n < 0)
c = 'N';
else
c = 'P';
write(1, &c, 1);
}

View File

@@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_comb.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 13:51:00 by gbaconni #+# #+# */
/* Updated: 2021/08/05 17:36:28 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_comb(void)
{
int x;
int y;
int z;
char str[3];
x = 0;
y = 1;
z = 2;
while (x <= 7)
{
while (y <= 8)
{
while (z <= 9)
{
str[0] = x + '0';
str[1] = y + '0';
str[2] = z + '0';
write(1, &str, 3);
if (z++ != 9 || y != 8 || x != 7)
write(1, ", ", 2);
}
z = ++y + 1;
}
y = ++x;
}
}

View File

@@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_comb2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 17:39:09 by gbaconni #+# #+# */
/* Updated: 2021/08/06 11:45:50 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_print_comb2(void)
{
int x;
int y;
char str[2];
x = 0;
while (x <= 99)
{
y = 1;
while (y <= 99)
{
str[0] = (x / 10) + '0';
str[1] = (x % 10) + '0';
write(1, &str, 2);
write(1, " ", 1);
str[0] = (y / 10) + '0';
str[1] = (y % 10) + '0';
write(1, &str, 2);
if (y != 99 || x != 99)
write(1, ", ", 2);
y++;
}
x++;
}
}

View File

@@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/05 18:09:22 by gbaconni #+# #+# */
/* Updated: 2021/08/06 11:48:21 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int nb)
{
char str[10];
int i;
i = 0;
if (nb == 0)
write(1, "0", 1);
while (nb != 0)
{
str[i] = nb % 10 + '0';
nb /= 10;
i++;
}
while (i > 0)
{
--i;
if (str[i] >= 48 && str[i] <= 57)
write(1, &str[i], 1);
}
}

View File

@@ -0,0 +1,85 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_combn.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/06 09:43:06 by gbaconni #+# #+# */
/* Updated: 2021/08/06 11:38:05 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int nb)
{
char str[10];
int i;
i = 0;
if (nb == 0)
write(1, "0", 1);
while (nb != 0)
{
str[i] = nb % 10 + '0';
nb /= 10;
i++;
}
while (i > 0)
{
--i;
if (str[i] >= 48 && str[i] <= 57)
write(1, &str[i], 1);
}
}
int power(int x, int n)
{
int r;
r = 1;
while (n--)
r *= x;
return (r);
}
int ndigits(int n)
{
int r;
r = 1;
if (n < 0)
{
if (n == 0)
n = 2147483647;
else
n = -n;
}
while (n > 9)
{
n /= 10;
r++;
}
return (r);
}
void ft_print_combn(int n)
{
int x;
int z;
int max;
max = power(10, n) - 1;
x = 1;
while (x <= max)
{
z = n - ndigits(x);
while (z-- > 0)
write(1, "0", 1);
ft_putnbr(x);
if (x != max)
write(1, ", ", 2);
x++;
}
}