-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C Piscine C 00 - OK 100% (2019-11-27)
- Loading branch information
Amanda Puchille pinha
committed
Dec 4, 2019
1 parent
0f03bef
commit 0143c0e
Showing
30 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_putchar.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/21 21:36:12 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/21 22:03:21 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putchar(char c) | ||
{ | ||
write(1, &c, 1); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_putchar(char c); | ||
|
||
int main(void) | ||
{ | ||
ft_putchar('c'); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_alphabet.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/21 22:27:05 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/21 22:41:03 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putchar(char c) | ||
{ | ||
write(1, &c, 1); | ||
} | ||
|
||
void ft_print_alphabet(void) | ||
{ | ||
char alphabet; | ||
|
||
alphabet = 'a'; | ||
while (alphabet <= 'z') | ||
{ | ||
ft_putchar(alphabet); | ||
alphabet++; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_print_alphabet(void); | ||
|
||
int main(void) | ||
{ | ||
ft_print_alphabet(); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_reverse_alphabet.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/21 23:38:44 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/21 23:48:02 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putchar(char c) | ||
{ | ||
write(1, &c, 1); | ||
} | ||
|
||
void ft_print_reverse_alphabet(void) | ||
{ | ||
char rev_alph; | ||
|
||
rev_alph = 'z'; | ||
while (rev_alph >= 'a') | ||
{ | ||
ft_putchar(rev_alph); | ||
rev_alph--; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_print_reverse_alphabet(void); | ||
|
||
int main(void) | ||
{ | ||
ft_print_reverse_alphabet(); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_numbers.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/22 00:22:33 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/22 00:31:18 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putchar(char c) | ||
{ | ||
write(1, &c, 1); | ||
} | ||
|
||
void ft_print_numbers(void) | ||
{ | ||
char num; | ||
|
||
num = '0'; | ||
while (num <= '9') | ||
{ | ||
ft_putchar(num); | ||
num++; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_print_numbers(void); | ||
|
||
int main(void) | ||
{ | ||
ft_print_numbers(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_is_negative.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/22 00:42:03 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/22 00:54:21 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_is_negative(int n) | ||
{ | ||
char pos; | ||
char neg; | ||
|
||
pos = 'P'; | ||
neg = 'N'; | ||
if (n >= 0) | ||
{ | ||
write(1, &pos, 1); | ||
} | ||
else | ||
{ | ||
write(1, &neg, 1); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_is_negative(int n); | ||
|
||
int main (void) | ||
{ | ||
ft_is_negative(-2); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_comb.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/22 20:42:11 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/22 23:51:06 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_3num(char a, char b, char c) | ||
{ | ||
write(1, &a, 1); | ||
write(1, &b, 1); | ||
write(1, &c, 1); | ||
if (a != '7' || b != '8' || c != '9') | ||
{ | ||
write(1, ", ", 2); | ||
} | ||
} | ||
|
||
void ft_print_comb(void) | ||
{ | ||
char d; | ||
char e; | ||
char f; | ||
|
||
d = '0'; | ||
while (d <= '7') | ||
{ | ||
e = d + 1; | ||
while (e <= '8') | ||
{ | ||
f = e + 1; | ||
while (f <= '9') | ||
{ | ||
ft_3num(d, e, f); | ||
f++; | ||
} | ||
e++; | ||
} | ||
d++; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_print_comb(void); | ||
|
||
int main(void) | ||
{ | ||
ft_print_comb(); | ||
return(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_comb2.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/23 12:46:23 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/24 15:30:20 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putchar2(char a, char b) | ||
{ | ||
write(1, &a, 1); | ||
write(1, &b, 1); | ||
} | ||
|
||
void ft_putint(int num, int max) | ||
{ | ||
char ch_u; | ||
char ch_d; | ||
|
||
if (num <= 9) | ||
{ | ||
ch_u = num + 48; | ||
ft_putchar2('0', ch_u); | ||
} | ||
else if (num <= max) | ||
{ | ||
ch_u = (num % 10) + 48; | ||
ch_d = (num / 10) + 48; | ||
ft_putchar2(ch_d, ch_u); | ||
} | ||
} | ||
|
||
void ft_catint(int fir, int sec) | ||
{ | ||
ft_putint(fir, 98); | ||
write(1, " ", 1); | ||
ft_putint(sec, 99); | ||
if (fir != 98 || sec != 99) | ||
ft_putchar2(',', ' '); | ||
} | ||
|
||
void ft_print_comb2(void) | ||
{ | ||
int f; | ||
int s; | ||
|
||
f = 0; | ||
while (f <= 98) | ||
{ | ||
s = f + 1; | ||
while (s <= 99) | ||
{ | ||
ft_catint(f, s); | ||
s++; | ||
} | ||
f++; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void ft_print_comb2(void); | ||
|
||
int main(void) | ||
{ | ||
ft_print_comb2(); | ||
return(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_putnbr.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/24 23:05:11 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/24 23:52:20 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putchar(char a) | ||
{ | ||
write(1, &a, 1); | ||
} | ||
|
||
void ft_putnbr(int nb) | ||
{ | ||
if (nb == -2147483648) | ||
{ | ||
ft_putchar('-'); | ||
ft_putchar('2'); | ||
nb = 147483648; | ||
} | ||
if (nb < 0) | ||
{ | ||
ft_putchar('-'); | ||
nb *= -1; | ||
} | ||
if (nb < 10) | ||
{ | ||
ft_putchar(nb + 48); | ||
return ; | ||
} | ||
else | ||
ft_putnbr(nb / 10); | ||
ft_putnbr(nb % 10); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
|
||
void ft_putnbr(int n); | ||
|
||
int main(void) | ||
{ | ||
printf(" (printed) should be 1"); | ||
ft_putnbr(1); | ||
printf("\n (printed) should be 0"); | ||
ft_putnbr(0); | ||
printf("\n (printed) should be -1"); | ||
ft_putnbr(-1); | ||
printf("\n (printed) should be 2147483647"); | ||
ft_putnbr(2147483647); | ||
printf("\n (printed) should be -21474836478"); | ||
ft_putnbr(-2147483648); | ||
printf("\n"); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdlib.h> | ||
|
||
void ft_putnbr(int nb); | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
char *av = argv[1]; | ||
int nbr = atoi(av); | ||
|
||
ft_putnbr(nbr); | ||
return(0); | ||
} |
Oops, something went wrong.
0143c0e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tnx