public class Solution {
public int Add(int num1,int num2) {
if(num1 == 0 && num2 == 0){
return 0;
}
int temp = num1 ^ num2;//不进位
int tempS = (num1 & num2) << 1;//进位
if(tempS == 0){
return temp;
}else{
return temp + tempS;
}
}
}
剑指offer(48)不用加减乘除做加法
猜你喜欢
转载自blog.csdn.net/qq_34403001/article/details/89298830
今日推荐
周排行