1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int x,bin; cin >> x; do { bin = 0; for(int i = 0; i < 4; i++) { bin += (x & 0x01)*pow(2,i); x = x >> 1; } cout << uppercase << hex << bin; }while(x); cout << endl; return 0; }