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