first commit
This commit is contained in:
7
ended/C00/ex00/ft_putchar.c
Normal file
7
ended/C00/ex00/ft_putchar.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
14
ended/C00/ex01/ft_print_alphabet.c
Normal file
14
ended/C00/ex01/ft_print_alphabet.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char ch;
|
||||
|
||||
ch = 'a';
|
||||
while (ch <= 'z')
|
||||
{
|
||||
write(1, &ch, 1);
|
||||
ch++;
|
||||
}
|
||||
}
|
14
ended/C00/ex02/ft_print_reverse_alphabet.c
Normal file
14
ended/C00/ex02/ft_print_reverse_alphabet.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_reverse_alphabet(void)
|
||||
{
|
||||
char ch;
|
||||
|
||||
ch = 'z';
|
||||
while (ch >= 'a')
|
||||
{
|
||||
write(1, &ch, 1);
|
||||
ch--;
|
||||
}
|
||||
}
|
14
ended/C00/ex03/ft_print_numbers.c
Normal file
14
ended/C00/ex03/ft_print_numbers.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_numbers(void)
|
||||
{
|
||||
char n;
|
||||
|
||||
n = '0';
|
||||
while (n <= '9')
|
||||
{
|
||||
write(1, &n, 1);
|
||||
n++;
|
||||
}
|
||||
}
|
14
ended/C00/ex04/ft_is_negative.c
Normal file
14
ended/C00/ex04/ft_is_negative.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_is_negative(int n)
|
||||
{
|
||||
if (n < 0)
|
||||
{
|
||||
write(1, "N", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
write(1, "P", 1);
|
||||
}
|
||||
}
|
37
ended/C00/ex05/ft_print_comb.c
Normal file
37
ended/C00/ex05/ft_print_comb.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_nb(char a, char b, char c)
|
||||
{
|
||||
write(1, &a, 1);
|
||||
write(1, &b, 1);
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_print_comb(void)
|
||||
{
|
||||
char a;
|
||||
char b;
|
||||
char c;
|
||||
|
||||
a = '0';
|
||||
while (a <= '7')
|
||||
{
|
||||
b = a + 1;
|
||||
while (b <= '8')
|
||||
{
|
||||
c = b + 1;
|
||||
while (c <= '9')
|
||||
{
|
||||
ft_print_nb(a, b, c);
|
||||
if (a != '7')
|
||||
{
|
||||
write(1, ", ", 2);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
b++;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
}
|
57
ended/C00/ex06/ft_print_comb2.c
Normal file
57
ended/C00/ex06/ft_print_comb2.c
Normal file
@ -0,0 +1,57 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void convert_nb(char nb1, char nb1_10, char nb2, char nb2_10)
|
||||
{
|
||||
char r_nb1;
|
||||
char r_nb1_10;
|
||||
char r_nb2;
|
||||
char r_nb2_10;
|
||||
|
||||
r_nb1 = nb1 + 48;
|
||||
r_nb1_10 = nb1_10 + 48;
|
||||
r_nb2 = nb2 + 48;
|
||||
r_nb2_10 = nb2_10 + 48;
|
||||
write(1, &r_nb2_10, 1);
|
||||
write(1, &r_nb2, 1);
|
||||
write(1, " ", 1);
|
||||
write(1, &r_nb1_10, 1);
|
||||
write(1, &r_nb1, 1);
|
||||
}
|
||||
|
||||
void get_nb(char a, char b)
|
||||
{
|
||||
char nb1;
|
||||
char nb2;
|
||||
char nb1_10;
|
||||
char nb2_10;
|
||||
|
||||
nb1 = a % 10;
|
||||
nb2 = b % 10;
|
||||
nb1_10 = a / 10;
|
||||
nb2_10 = b / 10;
|
||||
convert_nb(nb1, nb1_10, nb2, nb2_10);
|
||||
}
|
||||
|
||||
void ft_print_comb2(void)
|
||||
{
|
||||
char nb1;
|
||||
char nb2;
|
||||
|
||||
nb1 = 0;
|
||||
nb2 = 0;
|
||||
while (nb2 <= 98)
|
||||
{
|
||||
nb1 = nb2 + 1;
|
||||
while (nb1 <= 99)
|
||||
{
|
||||
get_nb(nb1, nb2);
|
||||
nb1++;
|
||||
if (nb2 < 98 || nb1 < 99)
|
||||
{
|
||||
write(1, ", ", 2);
|
||||
}
|
||||
}
|
||||
nb2++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user