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