add ex0{3..8}

This commit is contained in:
Aleksei Chubukov 2023-11-22 22:15:58 +04:00
parent de6099c26d
commit d75ddf60ed
6 changed files with 85 additions and 0 deletions

14
c01/ex03.c Normal file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
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;
}

11
c01/ex04.c Normal file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
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);
}

6
c01/ex05.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
void ft_putstr(char *str);
int main(void)
{
ft_putstr("hello world!\0no!");
}

8
c01/ex06.c Normal file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
int ft_strlen(char *str);
int main(void)
{
int l = ft_strlen("hello world!\0no!");
printf("len = %d\n", l);
}

23
c01/ex07.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
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);
}

23
c01/ex08.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
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);
}