4.unsignedint intvert(unsigned int x,int p,intn)实现对x的进行转换,p为起始转化位,n为需em要转换的长度,假设起始点在右边.如x=0b00010001,p=4,n=3转换后x=0b01100001
unsignedint intvert(unsigned int x,int p,int n)
{
unsignedint _t = 0;
unsignedint _a = 1;
for(inti = 0; i < n; ++i)
{
_t|= _a;
_a= _a << 1;
}
_t= _t << p;
x^= _t;
returnx;
}