题意为 让m插入到n的第j位到第i位
方法1:
class BinInsert {
public:
int binInsert(int n, int m, int j, int i) {
// write code here
for(int k=0;k)
{
n|=((m>>k)&1)<k);
}
return n;
}
};
&就是取 |就是插入
方法二:
class BinInsert {
public:
int binInsert(int n, int m, int j, int i) {
// write code here
return n|=m<<j;
}
};
Original: https://www.cnblogs.com/LonelyMoNan/p/16735464.html
Author: lemon-Breeze
Title: 二进制插入
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/607223/
转载文章受原作者版权保护。转载请注明原作者出处!