网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  【leetcode】数字的补数

【leetcode】数字的补数

分类: IT文章 • 2024-01-22 16:05:43
int findComplement(int num){
    int sum =0,pst=0;
    while(num){
        if ((num & 1) == 0)
        {
            sum += pow(2,pst);            
        }
        num >>= 1;
        pst++;
    }
    return sum;
}

相关推荐

  • leetcode 31. Next Permutation(字典序的下一个)
  • c++ 模板实现字符串数字之间的转换
  • js字符串和数字之间的大小对比!
  • LeetCode-020有效的括号 题目描述: 解析:
  • LeetCode T572.SubTree of Another Tree/另一棵树的子树
  • 剑指offer-06-旋转数组的最小数字
  • 数字逻辑-进制的转换
  • LeetCode 238. 除自身以外数组的乘积
  • LeetCode 26. 删除排序数组中的重复项
  • LeetCode 1431. 拥有最多糖果的孩子
  • C语言中的多线程
  • struts2.0 验证框架中message的替换有关问题
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号