#include <stdio.h>
#include <stdlib.h>
unsigned invert(unsigned int x,int p,int n)
{
return x^ (~(~0<<n)<<(p+1-n)); //异或操作 1^1=0 0^0=0 1^0=1 0^1=1
//用或操作,已完成,比较麻烦
/*return x & (~((~(~0<<n))<<(p+1-n)))
| ( ( (~( (x)>>(p+1-n) ) & ( ~(~0<<n) ))&(~(~0<<n))) <<(p+1-n) );*/
}
int main()
{
int x=0xd5;
unsigned int m;
m=invert(x,4,3);
printf(" %x ",m);
return 0;
}