Problem1364--写入连续的位

1364: 写入连续的位

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 48  Solved: 25
[Submit] [Status] [Web Board] [Creator:]

Description

实现函数setbits(unsigned *p, unsigned start, unsigned end, unsigned data);
修改指针p对应的无符号整数,只修改[start, end]对应的那几个bit。将数据修改成data。
例如
unsigned m = 9;  //内部二进制为 1001.
setbits(&m, 1,2,3);  //会将m修改成  1111,
printf("%u", m);  此时m的值为15。

Input

9 1 2 3

Output

15

Sample Input

9 1 2 3

Sample Output

15

HINT

void setbits(unsigned *p, unsigned start, unsigned end, unsigned data); 

Source/Category

 

[Submit] [Status]