Update Exo4
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/03/13 14:01:47 by lclerel- #+# #+# */
|
/* Created: 2026/03/13 14:01:47 by lclerel- #+# #+# */
|
||||||
/* Updated: 2026/03/13 14:30:30 by lclerel- ### ########.fr */
|
/* Updated: 2026/03/14 18:46:11 by Syxpi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -34,13 +34,13 @@ int ft_is_sort(int *tab, int length, int (*f)(int, int))
|
|||||||
if (f(tab[i], tab[i + 1]) < 0)
|
if (f(tab[i], tab[i + 1]) < 0)
|
||||||
{
|
{
|
||||||
ds = 0;
|
ds = 0;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return (cs || ds);
|
return (cs || ds);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ft_putnbr(int nb)
|
/*void ft_putnbr(int nb)
|
||||||
{
|
{
|
||||||
char value;
|
char value;
|
||||||
|
|
||||||
@@ -62,12 +62,36 @@ void ft_putnbr(int nb)
|
|||||||
write(1, &value, 1);
|
write(1, &value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ft_compare(int a, int b)
|
||||||
|
{
|
||||||
|
return (a - b);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int tab[] = {1, 2, 3, 4, 5, 6, 9, 7};
|
int croiss[] = {1, 2, 3, 4, 5, 6, 6, 7};
|
||||||
|
int decroiss[] = {7, 6, 6, 5, 4, 3, 2, 1};
|
||||||
|
int pas_trie[] = {1, 2, 3, 5, 6, 7, 6, 9};
|
||||||
|
|
||||||
if (ft_is_sort(tab, 8, &ft_putnbr == 1))
|
write(1, "Test Croissant : ", 17);
|
||||||
{
|
if (ft_is_sort(croiss, 8, &ft_compare) == 1)
|
||||||
write(1, "Ok :3", 5);
|
write(1, "Ok :3 (Trié)\n", 14);
|
||||||
}
|
else
|
||||||
}
|
write(1, "Not ok (Pas trié)\n", 19);
|
||||||
|
|
||||||
|
// Test 2 : Décroissant
|
||||||
|
write(1, "Test Decroissant : ", 19);
|
||||||
|
if (ft_is_sort(decroiss, 8, &ft_compare) == 1)
|
||||||
|
write(1, "Ok :3 (Trié)\n", 14);
|
||||||
|
else
|
||||||
|
write(1, "Not ok (Pas trié)\n", 19);
|
||||||
|
|
||||||
|
// Test 3 : Pas trié
|
||||||
|
write(1, "Test Pas trier : ", 17);
|
||||||
|
if (ft_is_sort(pas_trie, 8, &ft_compare) == 1)
|
||||||
|
write(1, "Ok :3 (Trié)\n", 14);
|
||||||
|
else
|
||||||
|
write(1, "Not ok (Pas trié)\n", 19);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}*/
|
||||||
|
|||||||
Reference in New Issue
Block a user