二进制插入

二进制插入

http://www.nowcoder.com/questionTerminal/30c1674ad5694b3f8f0bc2de6f005490

class BinInsert {
public:
    int binInsert(int n, int m, int j, int i) {
        // write code here
        // 插入位置          *** **
        //1024         0100 0000 0000    
        //19                   1 0011
        //左移j位            100 1100   加法或者按位或运算
        //------------------------------
        //1100        0100 0100 1100

        //本质:n加上m扩大2^j次方的结果作为返回值
            m=m<<j;
            return n+m;
        //  return n|m;
    }
};
全部评论

相关推荐

2025-12-17 13:34
复旦大学 算法工程师
回家当保安:复旦✌🏻,佬你的简历感觉挺好的,寒假日常hc比较少。佬可以过完年之后再试试,日常实习hc比较充足
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务