unsigned int invert(unsigned int x,int p,int n)实现对x的进行转换,p为起始转化位,n为需要转换的长度,假设起始点在右边.如x=0b0001 0001,p=4,n=3转换后x=0b0110 0001
unsigned int intvert(unsigned int x,int p,int n) //假定p=4,n=3
{
unsigned int t = 0;
unsigned int a = 1;
for(int i = 0; i < n; ++i)//循环的目的主要是获得t,n位全1的二进制数
{
t |= a; //位或
a <<= 1;
}
t << =p; //转换后_t变为1110000
x ^= t; /异或,将原来的位取反
return x;
}