From d75ddf60ed8060f1827a2b292fee7318c8aec0a2 Mon Sep 17 00:00:00 2001 From: Aleksei Chubukov Date: Wed, 22 Nov 2023 22:15:58 +0400 Subject: [PATCH] add ex0{3..8} --- c01/ex03.c | 14 ++++++++++++++ c01/ex04.c | 11 +++++++++++ c01/ex05.c | 6 ++++++ c01/ex06.c | 8 ++++++++ c01/ex07.c | 23 +++++++++++++++++++++++ c01/ex08.c | 23 +++++++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100644 c01/ex03.c create mode 100644 c01/ex04.c create mode 100644 c01/ex05.c create mode 100644 c01/ex06.c create mode 100644 c01/ex07.c create mode 100644 c01/ex08.c diff --git a/c01/ex03.c b/c01/ex03.c new file mode 100644 index 0000000..7d6874b --- /dev/null +++ b/c01/ex03.c @@ -0,0 +1,14 @@ +#include +void ft_div_mod(int a, int b, int *div, int *mod); +int main(void) +{ + int x = 42; + int y = 5; + int d = -999; + int m = -666; + + printf("was: %d %d /%d %%%d\n", x, y, d, m); + ft_div_mod(x, y, &d, &m); + printf("now: %d %d /%d %%%d\n", x, y, d, m); + return 0; +} diff --git a/c01/ex04.c b/c01/ex04.c new file mode 100644 index 0000000..94b2cf0 --- /dev/null +++ b/c01/ex04.c @@ -0,0 +1,11 @@ +#include +void ft_ultimate_div_mod(int *a, int *b); +int main() +{ + int m=42; + int n=5; + printf("was: =%d =%d\n", m, n); + ft_ultimate_div_mod(&m, &n); + printf("was: /%d %%%d\n", m, n); +} + diff --git a/c01/ex05.c b/c01/ex05.c new file mode 100644 index 0000000..3dcde55 --- /dev/null +++ b/c01/ex05.c @@ -0,0 +1,6 @@ +#include +void ft_putstr(char *str); +int main(void) +{ + ft_putstr("hello world!\0no!"); +} diff --git a/c01/ex06.c b/c01/ex06.c new file mode 100644 index 0000000..5d0971a --- /dev/null +++ b/c01/ex06.c @@ -0,0 +1,8 @@ +#include +int ft_strlen(char *str); +int main(void) +{ + int l = ft_strlen("hello world!\0no!"); + + printf("len = %d\n", l); +} diff --git a/c01/ex07.c b/c01/ex07.c new file mode 100644 index 0000000..2f836aa --- /dev/null +++ b/c01/ex07.c @@ -0,0 +1,23 @@ +#include +void ft_rev_int_tab(int *tab, int size); + +void printarr(int *arr, int len) +{ + int i = 0; + while (i < len) + { + printf("%d ", arr[i]); + i++; + } +} + +int main(void) +{ + int a[10] = {1, 3, 5, 7, 9, 11, 13, 15, 17}; + int l = 9; + + printarr(a, l); + printf("\n"); + ft_rev_int_tab(a, l); + printarr(a, l); +} diff --git a/c01/ex08.c b/c01/ex08.c new file mode 100644 index 0000000..7215f08 --- /dev/null +++ b/c01/ex08.c @@ -0,0 +1,23 @@ +#include + +void printarr(int *arr, int len) +{ + int i = 0; + while (i < len) + { + printf("%d ", arr[i]); + i++; + } + printf("\n"); +} + +void ft_sort_int_tab(int *tab, int size); +int main(void) +{ + int l = 21; + int a[21] = {4864, 3701, 20180, 26376, 32663, 15756, 18510, 1899, 9799, 13343, 25186, 7746, 8528, 7746, 11579, 4635, 25883, 23006, 3988, 21611, 26591}; + printarr(a, l); + ft_sort_int_tab(a, l); + printarr(a, l); + return (0); +}