程序员面试金典——5.1二进制插入
Solution1:题目要求严格了就是好啊。。
class BinInsert {
public:
int binInsert(int n, int m, int j, int i) {//题目中保证n的j至i位均为零
// write code here //m的二进制位数小于等于i-j+1
int m_copy = m << j;
return n + m_copy;
}
};