Compare commits

..
4 Commits
Author SHA1 Message Date
lclerel- lclerel- 9986e5a611 Ex1 et Ex2 fait 2026-03-05 15:59:01 +01:00
lclerel- lclerel- e08aa8e656 Ex1 et Ex2 fait 2026-03-05 15:58:51 +01:00
lclerel- lclerel- 0bf0139288 Update 2026-03-05 13:41:51 +01:00
lclerel- lclerel- 66ac4c00a4 Test 2026-03-05 13:41:04 +01:00
5 changed files with 9 additions and 82 deletions
+5 -6
View File
@@ -6,7 +6,7 @@
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/05 13:17:20 by lclerel- #+# #+# */
/* Updated: 2026/03/06 10:25:12 by lclerel- ### ########.fr */
/* Updated: 2026/03/05 13:37:09 by lclerel- ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,12 +21,12 @@ void ft_putnbr(int nb)
write(1, "-2147483648", 11);
return ;
}
if (nb < 0)
else if (nb < 0)
{
write(1, "-", 1);
nb = -nb;
}
if (nb > 9)
else if (nb > 9)
{
ft_putnbr(nb / 10);
}
@@ -34,9 +34,8 @@ void ft_putnbr(int nb)
write(1, &value, 1);
}
/*int main(void)
int main(void)
{
ft_putnbr(42);
ft_putnbr(-2147483647);
return (0);
}*/
}
+1 -1
View File
@@ -6,7 +6,7 @@
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/05 09:00:24 by lclerel- #+# #+# */
/* Updated: 2026/03/06 10:56:51 by lclerel- ### ########.fr */
/* Updated: 2026/03/05 15:40:40 by lclerel- ### ########.fr */
/* */
/* ************************************************************************** */
+3 -3
View File
@@ -6,7 +6,7 @@
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/05 13:45:48 by lclerel- #+# #+# */
/* Updated: 2026/03/05 19:09:34 by lclerel- ### ########.fr */
/* Updated: 2026/03/05 15:56:57 by lclerel- ### ########.fr */
/* */
/* ************************************************************************** */
@@ -43,8 +43,8 @@ void ft_print_comb2(void)
}
}
/*int main(void)
int main(void)
{
ft_print_comb2();
return (0);
}*/
}
View File
-72
View File
@@ -1,72 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_combn.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/05 19:08:08 by lclerel- #+# #+# */
/* Updated: 2026/03/05 19:08:53 by lclerel- ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_put_tab(int *tab, int n)
{
int i;
char c;
i = 0;
while (i < n)
{
c = tab[i] + '0';
write(1, &c, 1);
i++;
}
if (tab[0] != (10 - n))
{
write(1, ", ", 2);
}
}
void ft_recursive(int *tab, int n, int pos, int start)
{
int i;
if (pos == n)
{
ft_put_tab(tab, n);
return ;
}
i = start;
while (i <= 9)
{
tab[pos] = i;
ft_recursive(tab, n, pos + 1, i + 1);
i++;
}
}
void ft_print_combn(int n)
{
int tab[10];
if (n > 0 && n < 10)
{
ft_recursive(tab, n, 0, 0);
}
}
/*int main(void)
{
write(1, "Test n = 2 :\n", 13);
ft_print_combn(2);
write(1, "\n\n", 2);
write(1, "Test n = 3 :\n", 13);
ft_print_combn(3);
write(1, "\n\n", 2);
write(1, "Test n = 9 :\n", 13);
ft_print_combn(9);
write(1, "\n\n", 2);
}*/