| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
恶心的位运算,贴个代码#include <iostream>
using namespace std;
int main()
{
int r, x, y, bit11, bit0, x0;
scanf("%x,%d,%d", &r, &x, &y);
bit11 = 3 << y - 1;
bit0 = ((-1) << y - 2) - 1;
x0 = ((-1) << x) - 1;
r |= bit11;
r &= bit0;
r &= x0;
printf("%x\n", r);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator