diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-02 23:44:43 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-02 23:44:43 +0200 |
| commit | 9bde00749e9944c357267a024b3ec78d81a6799c (patch) | |
| tree | da718a1c479f0846d29326c63e925a35c1e9d4ee /c00 | |
| parent | 194a9c63eea7c053ea8eddcc6e24a5f4053febe7 (diff) | |
| download | piscine-9bde00749e9944c357267a024b3ec78d81a6799c.tar.gz piscine-9bde00749e9944c357267a024b3ec78d81a6799c.tar.bz2 piscine-9bde00749e9944c357267a024b3ec78d81a6799c.zip | |
c00 start, shell01 ex01 correcion
Diffstat (limited to 'c00')
| -rw-r--r-- | c00/ex00/ft_putchar.c | 28 | ||||
| -rw-r--r-- | c00/ex01/ft_print_alphabet.c | 33 | ||||
| -rw-r--r-- | c00/ex02/ft_print_reverse_alphabet.c | 33 | ||||
| -rw-r--r-- | c00/ex03/ft_print_numbers.c | 33 | ||||
| -rw-r--r-- | c00/ex04/ft_is_negative.c | 36 | ||||
| -rw-r--r-- | c00/ex05/ft_print_comb.c | 61 |
6 files changed, 224 insertions, 0 deletions
diff --git a/c00/ex00/ft_putchar.c b/c00/ex00/ft_putchar.c new file mode 100644 index 0000000..b09b871 --- /dev/null +++ b/c00/ex00/ft_putchar.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/02 22:03:32 by cacharle #+# #+# */ +/* Updated: 2019/07/02 22:33:32 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> + +void ft_putchar(char c); + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +int main(void) +{ + ft_putchar('a'); + ft_putchar('b'); + ft_putchar('c'); + return (0); +} diff --git a/c00/ex01/ft_print_alphabet.c b/c00/ex01/ft_print_alphabet.c new file mode 100644 index 0000000..f75442d --- /dev/null +++ b/c00/ex01/ft_print_alphabet.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_alphabet.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/02 22:18:43 by cacharle #+# #+# */ +/* Updated: 2019/07/02 22:33:52 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> + +void ft_print_alphabet(void); + +void ft_print_alphabet(void) +{ + char letter; + + letter = 'a'; + while (letter != 'z' + 1) + { + write(1, &letter, 1); + letter++; + } +} + +int main(void) +{ + ft_print_alphabet(); + return (0); +} diff --git a/c00/ex02/ft_print_reverse_alphabet.c b/c00/ex02/ft_print_reverse_alphabet.c new file mode 100644 index 0000000..d36b6c0 --- /dev/null +++ b/c00/ex02/ft_print_reverse_alphabet.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_reverse_alphabet.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/02 22:27:12 by cacharle #+# #+# */ +/* Updated: 2019/07/02 22:31:18 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> + +void ft_print_reverse_alphabet(void); + +void ft_print_reverse_alphabet(void) +{ + char letter; + + letter = 'z'; + while (letter != 'a' - 1) + { + write(1, &letter, 1); + letter--; + } +} + +int main(void) +{ + ft_print_reverse_alphabet(); + return (0); +} diff --git a/c00/ex03/ft_print_numbers.c b/c00/ex03/ft_print_numbers.c new file mode 100644 index 0000000..9f8f947 --- /dev/null +++ b/c00/ex03/ft_print_numbers.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_numbers.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/02 22:36:58 by cacharle #+# #+# */ +/* Updated: 2019/07/02 22:40:46 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> + +void ft_print_numbers(void); + +void ft_print_numbers(void) +{ + char number; + + number = '0'; + while (number != '9' + 1) + { + write(1, &number, 1); + number++; + } +} + +int main(void) +{ + ft_print_numbers(); + return (0); +} diff --git a/c00/ex04/ft_is_negative.c b/c00/ex04/ft_is_negative.c new file mode 100644 index 0000000..58c1b60 --- /dev/null +++ b/c00/ex04/ft_is_negative.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_is_negative.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/02 22:43:22 by cacharle #+# #+# */ +/* Updated: 2019/07/02 22:50:01 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> + +void ft_is_negative(int n); + +void ft_is_negative(int n) +{ + char negative_char; + char positive_char; + + negative_char = 'N'; + positive_char = 'P'; + if (n < 0) + write(1, &negative_char, 1); + else + write(1, &positive_char, 1); +} + +int main(void) +{ + ft_is_negative(-1); + ft_is_negative(1); + ft_is_negative(0); + return (0); +} diff --git a/c00/ex05/ft_print_comb.c b/c00/ex05/ft_print_comb.c new file mode 100644 index 0000000..1a1ddf3 --- /dev/null +++ b/c00/ex05/ft_print_comb.c @@ -0,0 +1,61 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_comb.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/02 22:55:29 by cacharle #+# #+# */ +/* Updated: 2019/07/02 23:14:29 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <unistd.h> + +void ft_print_comb(void); + +void write_xyz_comb(int x, int y, int z) +{ + char x_char; + char y_char; + char z_char; + + x_char = x + '0'; + y_char = y + '0'; + z_char = z + '0'; + write(1, &x_char, 1); + write(1, &y_char, 1); + write(1, &z_char, 1); +} + +void ft_print_comb(void) +{ + char x; + char y; + char z; + + x = 0; + y = 0; + z = 0; + while (x < 10) + { + while (y < 10) + { + while (z < 10) + { + if (x != y && x != z && y != z) + write_xyz_comb(x, y, z); + z++; + } + y++; + } + x++; + } +} + +int main(void) +{ + ft_print_comb(); + return (0); +} + |
