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