fork download
  1. #include <stdio.h>
  2.  
  3. void tohex(int n) {
  4. if (n == 0) return;
  5. tohex(n / 16);
  6.  
  7. int digit = n % 16;
  8. if (digit < 10)
  9. printf("%d",digit);
  10. else
  11. {switch(n%16){
  12. case 10:printf("A");
  13. break;
  14. case 11:printf("B");
  15. break;
  16. case 12: printf("C");
  17. break;
  18. case 13:printf("D");
  19. break;
  20. case 14: printf("E");
  21. break;
  22. case 15: printf("F");
  23. break;
  24. }
  25. }
  26. }
  27.  
  28. int main(void) {
  29. int n;
  30. scanf("%d", &n);
  31. if (n == 0)
  32. printf("0");
  33. else
  34. tohex(n);
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5324KB
stdin
25
stdout
19