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