practice 2-7:编写汉书invert(x,p,n)将x从第p位开始的n位求反,其余不变
#include
unsigned invert(unsigned x,int p,int n)
{
return x^(~(~0<<n)<<p-n+1);
}
main()
{
unsigned num,result;
int m,n;
scanf("%d,%d,%d",&num,&m,&n);
result=invert(num,m,n);
printf("%d",result);
return 0;
}