1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| #include <stdlib.h>
void my_putchar(char c)
{
write(1 ,&c, 1);
}
int my_put_nbr(int n)
{
int fin;
int debut;
if (n < 0)
{
my_putchar('-');
my_put_nbr(-n);
}
else
{
fin = n % 10;
debut = n / 10;
if (debut !=0)
my_put_nbr(debut);
my_putchar(fin + '0');
}
}
int my_calc(int nb1, int nb2)
{
int res;
res = nb1 + nb2;
return(res);
}
int my_getnbr(char *str)
{
int result;
int fact_mult;
int i;
fact_mult = 1;
result = 0;
i = strlen(str) - 1;
while (i >= 0)
{
result = result + (fact_mult *(i - '0')) ;
fact_mult *= 10;
i--;
return (result);
}
}
int my_strlen(char *str)
{
int result;
result = 0;
while (str[result] != '\0')
{
result++;
}
return (result);
}
int main(int ac,char **av)
{
my_calc((my_getnbr(av[1])), (my_getnbr(av[3])));
} |
Partager