fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <set>
  4. #include <vector>
  5. #include <map>
  6. #include <climits>
  7. using namespace std;
  8.  
  9. long long mod = (long long)(1e9 + 7);
  10.  
  11. void decimalToHexa(long long n) {
  12. if (n == 0) {
  13. return;
  14. }
  15. decimalToHexa(n / 16);
  16. int digit = n % 16;
  17. if (digit < 10) {
  18. cout << digit;
  19. }
  20. else {
  21. if (digit == 10) {
  22. cout << 'A';
  23. }
  24. if (digit == 11) {
  25. cout << "B";
  26. }
  27. if (digit == 12) {
  28. cout << 'C';
  29. }
  30. if (digit == 13) {
  31. cout << "D";
  32. }
  33. if (digit == 14) {
  34. cout << 'E';
  35. }
  36. if (digit == 15) {
  37. cout << "F";
  38. }
  39. }
  40. }
  41. int main() {
  42. ios::sync_with_stdio(false);
  43. cin.tie(nullptr);
  44.  
  45. long long n;cin >> n;
  46. if (n == 0) {
  47. cout << 0;
  48. return 0;
  49. }
  50. decimalToHexa(n);
  51.  
  52. }
  53.  
Success #stdin #stdout 0s 544KB
stdin
Standard input is empty
stdout
12000