Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- int ft_putchar(char c)
- {
- write (1, &c, 1);
- return 0;
- }
- void ft_putnbr(int nb)
- {
- while (((nb % 10) != 0) || (nb >= 10))
- {
- ft_putchar ((nb % 10) + '0');
- nb = nb / 10;
- }
- }
- int ft_reverse(int nb)
- {
- int res;
- while (nb > 0)
- {
- res = ((nb % 10) * 10) + (nb % 10) % 10;
- nb = res;
- }
- return (res);
- }
- int main()
- {
- int a;
- scanf("%d", &a);
- ft_putnbr(ft_reverse(a));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment