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