Skip to content

Commit

Permalink
Última versão lista Basecamp-Reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
kechrist committed Apr 3, 2022
1 parent fea1621 commit 61f53a2
Show file tree
Hide file tree
Showing 25 changed files with 504 additions and 0 deletions.
Binary file added ex00/exo.tar
Binary file not shown.
1 change: 1 addition & 0 deletions ex01/z
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Z
1 change: 1 addition & 0 deletions ex02/clean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find . -type f \( -name '*~' -o -name '#*# \) -print -delete
2 changes: 2 additions & 0 deletions ex03/find_sh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
find . -type f -name "*.sh" -exec basename {} .sh \;
2 changes: 2 additions & 0 deletions ex04/MAC.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
ifconfig -a | grep ether | awk '{print $2}'
1 change: 1 addition & 0 deletions ex05/"\?$*'MaRViN'*$?\"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
22 changes: 22 additions & 0 deletions ex06/ft_print_alphabet.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_alphabet.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:11:05 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:11:13 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_putchar(char c);

void ft_print_alphabet(void)
{
char c;

c = 96;
while (++c < 123)
ft_putchar(c);
}
22 changes: 22 additions & 0 deletions ex07/ft_print_numbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_numbers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:12:28 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:12:40 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_putchar(char c);

void ft_print_numbers(void)
{
char c;

c = 47;
while (++c < 58)
ft_putchar(c);
}
21 changes: 21 additions & 0 deletions ex08/ft_is_negative.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_negative.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:14:15 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:14:34 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_putchar(char c);

void ft_is_negative(int n)
{
if (n >= 0)
ft_putchar('P');
else
ft_putchar('N');
}
16 changes: 16 additions & 0 deletions ex09/ft_ft.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ft.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:15:27 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:15:46 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_ft(int *nbr)
{
*nbr = 42;
}
20 changes: 20 additions & 0 deletions ex10/ft_swap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:16:35 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:16:49 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_swap(int *a, int *b)
{
int swap;

swap = *a;
*a = *b;
*b = swap;
}
17 changes: 17 additions & 0 deletions ex11/ft_div_mod.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_div_mod.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:17:54 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:17:59 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_div_mod(int a, int b, int *div, int *mod)
{
*div = a / b;
*mod = a % b;
}
30 changes: 30 additions & 0 deletions ex12/ft_iterative_factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_iterative_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:18:58 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:19:27 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

int ft_iterative_factorial(int nb)
{
int i;
int response;

i = 1;
response = 1;
if (nb < 0 || nb > 12)
return (0);
if (nb == 0 || nb == 1)
return (1);
while (i <= nb)
{
response *= i;
i++;
}
return (response);
}
21 changes: 21 additions & 0 deletions ex13/ft_recursive_factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_recursive_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:20:22 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:21:51 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

int ft_recursive_factorial(int nb)
{
if (nb < 0 || nb > 12)
return (0);
else if (nb == 0 || nb == 1)
return (1);
else
return (nb * ft_recursive_factorial(nb - 1));
}
29 changes: 29 additions & 0 deletions ex14/ft_sqrt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:21:56 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:24:43 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

int ft_sqrt(int nb)
{
int i;

i = 1;
if (nb <= 0)
return (0);
while (i * i < nb)
{
i++;
if (i == 46340)
break ;
}
if (i * i == nb)
return (i);
return (0);
}
19 changes: 19 additions & 0 deletions ex15/ft_putstr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:25:59 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:26:19 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_putchar(char c);

void ft_putstr(char *str)
{
while (*str)
ft_putchar(*str++);
}
21 changes: 21 additions & 0 deletions ex16/ft_strlen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:27:04 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:27:18 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

int ft_strlen(char *str)
{
int i;

i = -1;
while (str[++i])
;
return (i--);
}
21 changes: 21 additions & 0 deletions ex17/ft_strcmp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:28:07 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:28:27 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

int ft_strcmp(char *s1, char *s2)
{
int i;

i = 0;
while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0')
i++;
return (s1[i] - s2[i]);
}
32 changes: 32 additions & 0 deletions ex18/ft_print_params.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_params.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:29:11 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:29:27 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_putchar(char c);

int main(int argc, char **argv)
{
int i;
int j;

i = 1;
if (argc < 1)
return (0);
while (i < argc)
{
j = 0;
while (argv[i][j] != '\0')
ft_putchar(argv[i][j++]);
ft_putchar('\n');
i++;
}
return (0);
}
65 changes: 65 additions & 0 deletions ex19/ft_sort_params.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sort_params.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kechrist <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/03 23:30:02 by kechrist #+# #+# */
/* Updated: 2022/04/03 23:30:57 by kechrist ### ########.fr */
/* */
/* ************************************************************************** */

void ft_putchar(char c);

void ft_putstr(char *str)
{
while (*str)
ft_putchar(*str++);
}

int ft_strcmp(char *s1, char *s2)
{
int i;

i = 0;
while (s1[i] == s2[i] && s1[i] != !0 && s2[i] != !0)
i++;
return (s1[i] - s2[i]);
}

void ft_print_params(int argc, char **argv)
{
int i;

i = 1;
while (i < argc)
{
ft_putstr(argv[i++]);
ft_putchar('\n');
}
}

int main(int argc, char **argv)
{
int i;
char *swap;

i = 1;
if (argc > 1)
{
while (i < argc - 1)
{
if (ft_strcmp(argv[i], argv[i + 1]) > 0)
{
swap = argv[i];
argv[i] = argv[i + 1];
argv[i + 1] = swap;
i = 0;
}
i++;
}
ft_print_params(argc, argv);
}
return (0);
}
Loading

0 comments on commit 61f53a2

Please sign in to comment.