aboutsummaryrefslogtreecommitdiff
path: root/c00/ex06
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-03 16:37:50 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-03 16:37:50 +0200
commite65f1a0088a86af0426bc523f017631066cc9c42 (patch)
tree38c30d4c5cc60e20b2752cff3b2927af9a16f51a /c00/ex06
parent4205989a932533f528c0fa8f76126a5b57606c0a (diff)
downloadpiscine-e65f1a0088a86af0426bc523f017631066cc9c42.tar.gz
piscine-e65f1a0088a86af0426bc523f017631066cc9c42.tar.bz2
piscine-e65f1a0088a86af0426bc523f017631066cc9c42.zip
c00
Diffstat (limited to 'c00/ex06')
-rw-r--r--c00/ex06/ft_print_comb2.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/c00/ex06/ft_print_comb2.c b/c00/ex06/ft_print_comb2.c
new file mode 100644
index 0000000..7e6d2d1
--- /dev/null
+++ b/c00/ex06/ft_print_comb2.c
@@ -0,0 +1,49 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_print_comb2.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/03 08:32:30 by cacharle #+# #+# */
+/* Updated: 2019/07/03 14:28:09 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void my_putchar(char c)
+{
+ write(1, &c, 1);
+}
+
+void print_nb(int nb)
+{
+ my_putchar((char)(nb / 10 + '0'));
+ my_putchar((char)(nb % 10 + '0'));
+}
+
+void ft_print_comb2(void)
+{
+ int nb1;
+ int nb2;
+
+ nb1 = 0;
+ while (nb1 < 100)
+ {
+ nb2 = nb1 + 1;
+ while (nb2 < 100)
+ {
+ print_nb(nb1);
+ my_putchar(' ');
+ print_nb(nb2);
+ if (!(nb1 == 98 && nb2 == 99))
+ {
+ my_putchar(',');
+ my_putchar(' ');
+ }
+ nb2++;
+ }
+ nb1++;
+ }
+}