洛谷 P1100 高低位交换

在这里插入图片描述
思路:使用掩码运算得到的高16位与低16位取或

#include <bits/stdc++.h>
using namespace std;
int main()
{
	unsigned n;cin>>n;
	cout<<((n&0x0000ffff)<<16|(n&0xffff0000)>>16)<<endl;
	system("pause");
	return 0;
}
发布了99 篇原创文章 · 获赞 44 · 访问量 5519

猜你喜欢

转载自blog.csdn.net/weixin_44413191/article/details/103338016