<span style="font-size:32px;">unsigned char b = 0b00001000;
unsigned char left1 = 0; //存储左移后的结果
unsigned char right1 = 0; //存储右移后的结果
left1 = b << 1;
left1 = left1 & 0b10101010; //将奇数位清零
right1 = b >> 1;
right1 = right1 & 0b01010101;//将偶数位清零
printf("奇数位和偶数位互换为%d\n", left1 | right1);</span>
C语言-进制转换-输入一个字节的整数(0~255),然后将该数的转换为二进制数,然后将奇数位和偶数位互换
最新推荐文章于 2023-01-09 11:41:52 发布