Advertisement
STANAANDREY

tpa rec5

Apr 1st, 2023 (edited)
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.21 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int tohex(int x, int p) {
  4.   if (x == 0) {
  5.     return 0;
  6.   }
  7.   int dig = x % 10;
  8.   return tohex(x / 10, 16 * p) + dig * p;
  9. }
  10.  
  11. int main() {
  12.   printf("%d\n", tohex(312, 1));
  13.   return 0;
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement