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