Guest User

Untitled

a guest
Dec 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.    
  6.     int x;
  7.     cin >> x;
  8.        
  9.         if (x == 0)cout << "0" << endl;
  10.        
  11.         else{
  12.    
  13.             while(x >=16){
  14.        
  15.                 if (x >= 256){
  16.                     if (x%16 >= 10){
  17.                         char y;
  18.                         y = x%16 + 55;
  19.                         cout << y;
  20.                     }
  21.                     else cout << x%16;
  22.                 }
  23.                 else if(x < 256){
  24.                
  25.                     if (x%16 >= 10){
  26.                         char y;
  27.                         y = x%16 + 55;
  28.                         cout << y;
  29.                     }
  30.                     else cout << x%16;
  31.                
  32.                
  33.                     if (x/16 >= 10){
  34.                         char y;
  35.                         y = x/16 + 55;
  36.                         cout << y << endl;
  37.                     }
  38.                     else cout << x/16 << endl;
  39.                 }
  40.                 x = x/16;
  41.             }
  42.            
  43.        }
  44. }
Add Comment
Please, Sign In to add comment