371. Sum of Two Integers
来源:互联网 发布:淘宝秒杀流程 编辑:程序博客网 时间:2024/05/06 20:36
Calculate the sum of two integers a and b, but you are not allowed to use the operator +
and -
.
Example:
Given a = 1 and b = 2, return 3.
int getSum(int a, int b) { int result = a ^ b; int carry = (a & b) << 1; if (carry) return getSum(result, carry); return result;}为什么自己测试这个函数结果会不对呢??
0 0
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 371. Sum of Two Integers
- 上取整和下取整
- 选择法---排序(一维数组)
- Scala中的函数
- C++类对象数据成员的构造函数初始化顺序
- 说说学英语这件事
- 371. Sum of Two Integers
- 【53.61%】【BZOJ 2302】[HAOI2011]Problem c
- SphinxClient 类
- 程序人生之起步
- mysql数据库的查询(select)操作
- CRecordSet类用法
- Coco2d-x3.8.1制作飞翔的小鸟(上)
- 发现一个国外的学习网站
- 点亮第一盏LED灯,点亮另一片世界