码迷,mamicode.com
首页 > 其他好文 > 详细

不用+做加法

时间:2020-03-23 00:07:11      阅读:49      评论:0      收藏:0      [点我收藏+]

标签:color   temp   tps   solution   ref   不用   shu   turn   www   

 1 class Solution {
 2     public int add(int a, int b) {
 3         while(a != 0){
 4             int temp = a ^ b;
 5             a = ((a & b) << 1);
 6             b = temp;
 7         }
 8         return b;
 9     }
10 }

转自https://www.jianshu.com/p/247a06f1c382

不用+做加法

标签:color   temp   tps   solution   ref   不用   shu   turn   www   

原文地址:https://www.cnblogs.com/irisiscool/p/12549266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!