输入一个4字节的变量,拆成4个1字节的变量输出
示例Please Enter 4-byte Value:
0x[提示符]12345678
Result Is:
0x12
0x34
0x56
0x78
使用移位符>>和<<完成这个题目(注意)
程序代码:void cc(unsigned int a)
{
#define HALF_INT (sizeof(int) << 2)
#define HALF_SHORT (sizeof(short) << 2)
#define MASK_H 0xff00ff00
#define MASK_L 0x00ff00ff
a = (a << HALF_INT) | (a >> HALF_INT);
a = ((a << HALF_SHORT) & MASK_H) | ((a >> HALF_SHORT) & MASK_L);
do {
printf("0x%x\n",(unsigned char)(a));
} while (a>>=HALF_SHORT);
}希望对你有帮助
