eg0rmaffin

not working yet

Jul 8th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3.  
  4.  
  5.  
  6.  
  7.  
  8. int ft_putchar(char c)
  9. {
  10.     write (1, &c, 1);
  11.     return 0;
  12. }
  13.  
  14.  
  15.  
  16. void ft_putnbr(int nb)
  17. {
  18.     while (((nb % 10) != 0) || (nb >= 10))
  19.     {
  20.         ft_putchar ((nb % 10) + '0');
  21.         nb = nb / 10;
  22.     }
  23. }
  24.  
  25. int     ft_reverse(int nb)
  26. {
  27.     int res;
  28.     while (nb > 0)
  29.     {
  30.         res = ((nb % 10) * 10) + (nb % 10) % 10;
  31.         nb = res;
  32.     }
  33.     return (res);
  34. }
  35.  
  36.  
  37. int     main()
  38. {
  39.     int a;
  40.     scanf("%d", &a);
  41.     ft_putnbr(ft_reverse(a));
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment