Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

恶心的位运算,贴个代码

Posted by 307250217 at 2010-02-21 13:25:18 on Problem 3748
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator