src2020/2013_highlowchange/highlowchange.cpp

34 lines
602 B
C++
Raw Normal View History

2020-03-14 12:55:56 +08:00
#define DEBUG
2020-03-14 12:43:08 +08:00
#include <iostream>
using namespace std;
int main()
{
unsigned n;
int a[33] = { 0 }, i = 0, s = 1;
cin >> n;
while (n > 0) {
a[++i] = n % 2;
//cout<<a[i];
n /= 2;
}
#ifdef DEBUG
for (int j = 32; j >= 1; j--) {
if (j % 4 == 0)
cout << " ";
cout << a[j];
}
cout << endl;
#endif // DEBUG
for (int j = 1; j <= 16; j++) {
n += a[j + 16] * s;
s *= 2;
}
for (int j = 1; j <= 16; j++) {
n += a[j] * s;
s *= 2;
}
cout << n;
}