csp2021阅读程序第一题
#include <iostream>
using namespace std;
int main()
{
unsigned short x, y;
cin >> x >> y;
x = (x | x << 2)& 0x33;
cout<<"1 x is "<<x<<endl;
x = (x | x << 1)& 0x55;
cout<<"2 x is "<<x<<endl;
y = (y | y << 2)& 0x33;
cout<<"1 y is "<<x<<endl;
y = (y | y << 1)& 0x55;
cout<<"2 y is "<<x<<endl;
unsigned short z = x | y << 1;
cout << z << endl;
return 0;
}
解析:
|..............这是个取or运算
<<............这个是右移运算
ox33............这是代表16进制下的数字33


浙公网安备 33010602011771号