fork download
  1. #include <stdio.h>
  2.  
  3. int convert(int n){
  4.  
  5.  
  6.  
  7. switch(n){
  8.  
  9. case(10): printf("A");
  10.  
  11. case(11): printf("B");
  12.  
  13. case(12): printf("C");
  14.  
  15. case(13): printf("D");
  16.  
  17. case(14): printf("E");
  18.  
  19. case(15): printf("F");
  20.  
  21. default: printf("%d",n);
  22.  
  23.  
  24. }
  25.  
  26.  
  27. }
  28.  
  29. void tohex(int n){
  30.  
  31. if(n==0){
  32. return;
  33. }
  34.  
  35.  
  36. else {
  37.  
  38. tohex(n/16);
  39.  
  40. convert(n%16);
  41.  
  42. }
  43.  
  44. }
  45.  
  46. int main(void) {
  47.  
  48. int n;
  49.  
  50. scanf("%d",&n);
  51.  
  52. tohex(n);
  53.  
  54. return 0;
  55. }
Success #stdin #stdout 0s 5300KB
stdin
16
stdout
10