P1100 高低位交换

题目传送门

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;


int main() {
    //取第k位
    LL x;
    cin >> x;
    //& 0x0000ffff 是清空了前十六位
    //& 0xffff0000 是清空了后十六位
    // <<16 就把清空的前十六位整没了
    // >>16 就把清空的后十六位整没了
    // 两者再或一下,就是前后颠倒过来了
    cout << ((x & 0x0000ffff) << 16 | (x & 0xffff0000) >> 16) << endl;//万无一失的做法
    return 0;
}
原文地址:https://www.cnblogs.com/littlehb/p/15165533.html