/// a^b:异或运算,不进位加法运算。
        /// a&b:与运算,真真为真,(a&b)<<1:相同的进位
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static int aplusb(int a, int b)
        {
            if (b == 0) return a;
            int nocarry = a ^ b;
            int carry = (a & b) << 1;
            return aplusb(nocarry, carry);
        }

 

相关文章:

  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2021-12-25
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案