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