thegreatestmistakeyoucanmakeinlifeistobecontinuallyfearingyouwillmakeone。
-- Elbert Hubbard
将一个整数的高位调换的想法,取各数位,按指定顺序排列。
使用c语言记述的解法有以下几种。
《》
#包含
输入
是主(语音)
{
//unsigned short [ 0,65535 ]
//0xABCD=43981
unsigned short a=0xABCD;
unsigned short b,c,d;
打印(before convert (n0x % x (n ),a );
b=(a8 )0xFF00;
c=(a8 )0x00FF;
d=c | b;
打印(after convert (n0x % x (n ),d );
}
用c语言编写的解法。
《》
#包含
#include //I/O流控制头文件
using namespace std;
输入
是主(语音)
{
//unsighed shortint [ 0,65535 ]
unsigned short int a=0XABCD;
unsigned short int b,c,d;
cout 'Before convert '
endl
//大写显示
setiosflags (IOs :3360升级机箱)。
用hex //进制表示
' 0X '
a
endl;
b=(a8 ) 0Xff00;
c=(a8 ) 0X00ff;
d=c | b;
cout 'After convert '
endl
用hex //进制表示
' 0X '
d
endl;
}