题解 | #不用加减乘除做加法#

不用加减乘除做加法

http://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215

public class Solution { public int Add(int num1,int num2) { while(num2 != 0) { int n1 = num1; int n2 = num2; num1 = n1 ^ n2; num2 = (n1 & n2) << 1; }

    return num1;
}

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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