poj 3748 位操作
#include<iostream> //位运算
using namespace std;
int main()
{
int r,x,y;
scanf("%x,%d,%d",&r,&x,&y);
r=r&(~(1<<x));
r=r|(1<<y);
r=r|(1<<(y-1));
r=r&(~(1<<(y-2)));
printf("%x\n",r);
return 0;
}
#include<iostream> //位运算
using namespace std;
int main()
{
int r,x,y;
scanf("%x,%d,%d",&r,&x,&y);
r=r&(~(1<<x));
r=r|(1<<y);
r=r|(1<<(y-1));
r=r&(~(1<<(y-2)));
printf("%x\n",r);
return 0;
}