-
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 06 - OK 100% (2019-12-11)
- Loading branch information
Amanda Puchille pinha
committed
Dec 13, 2019
1 parent
10bb0ea
commit cdc3d20
Showing
8 changed files
with
177 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,30 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_program_name.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/12/09 14:10:42 by apuchill #+# #+# */ | ||
/* Updated: 2019/12/09 18:28:13 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
if (argc > 0) | ||
{ | ||
while (argv[0][c] != '\0') | ||
{ | ||
write(1, &argv[0][c], 1); | ||
c++; | ||
} | ||
write(1, "\n", 1); | ||
} | ||
return (0); | ||
} |
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,37 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_print_params.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/12/09 14:20:32 by apuchill #+# #+# */ | ||
/* Updated: 2019/12/09 18:28:30 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int c; | ||
int d; | ||
|
||
c = 1; | ||
d = 0; | ||
if (argc > 1) | ||
{ | ||
while (c < argc) | ||
{ | ||
d = 0; | ||
while (argv[c][d] != '\0') | ||
{ | ||
write(1, &argv[c][d], 1); | ||
d++; | ||
} | ||
write(1, "\n", 1); | ||
c++; | ||
} | ||
} | ||
return (0); | ||
} |
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,37 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_rev_params.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/12/09 14:20:32 by apuchill #+# #+# */ | ||
/* Updated: 2019/12/09 18:28:41 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int c; | ||
int d; | ||
|
||
c = argc - 1; | ||
d = 0; | ||
if (argc > 1) | ||
{ | ||
while (c > 0) | ||
{ | ||
d = 0; | ||
while (argv[c][d] != '\0') | ||
{ | ||
write(1, &argv[c][d], 1); | ||
d++; | ||
} | ||
write(1, "\n", 1); | ||
c--; | ||
} | ||
} | ||
return (0); | ||
} |
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,73 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_sort_params.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/12/09 16:33:03 by apuchill #+# #+# */ | ||
/* Updated: 2019/12/09 18:28:55 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <unistd.h> | ||
|
||
void ft_putstr(const char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
write(1, &str[c], 1); | ||
c++; | ||
} | ||
write(1, "\n", 1); | ||
} | ||
|
||
int ft_strcmp(const char *s1, const char *s2) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while ((s1[c] == s2[c]) && (s1[c] != '\0') && (s2[c] != '\0')) | ||
c++; | ||
return (s1[c] - s2[c]); | ||
} | ||
|
||
void ft_swap(int *a, int *b) | ||
{ | ||
int aux; | ||
|
||
aux = *a; | ||
*a = *b; | ||
*b = aux; | ||
} | ||
|
||
int main(int argc, const char **argv) | ||
{ | ||
int qty; | ||
int c; | ||
int d; | ||
int arg[argc]; | ||
|
||
qty = 1; | ||
c = 1; | ||
while (qty < argc) | ||
{ | ||
arg[qty] = qty; | ||
qty++; | ||
} | ||
while (c < argc) | ||
{ | ||
d = c; | ||
while (d < argc) | ||
{ | ||
if (ft_strcmp(argv[arg[c]], argv[arg[d]]) > 0) | ||
ft_swap(&arg[c], &arg[d]); | ||
d++; | ||
} | ||
ft_putstr(argv[arg[c++]]); | ||
} | ||
return (0); | ||
} |
Binary file not shown.