由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Write a function to add two numbers, without using any arithmetic operator.
相关主题
时针和分针角度问题Google 面试
fb两轮面试,据信两封Bloomberg phone interview (intern)
这道题有没有答案呀?问道看到的面试题
这道题,怎么做呀?c++ class default functions?
再出一题问几道面试题
这道题怎么做的?Onsite面经(EE)
C++ 一小题乘方函数还有简解么
有基础面试题么Ask a google interview question(2)
相关话题的讨论汇总
话题: add话题: write话题: arithmetic话题: operator话题: without
进入JobHunting版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
rt.
d********t
发帖数: 9628
2

CareerCup, logic & then carry

【在 c**********e 的大作中提到】
: rt.
S**I
发帖数: 15689
3
经典老题:
int add_no_arithm(int a, int b) {
if (b == 0) return a;
int sum = a ^ b; // add without carrying
int carry = (a & b) << 1; // carry, but don't add
return add_no_arithm(sum, carry); // recurse
}

【在 c**********e 的大作中提到】
: rt.
d********t
发帖数: 9628
4

Nice!

【在 S**I 的大作中提到】
: 经典老题:
: int add_no_arithm(int a, int b) {
: if (b == 0) return a;
: int sum = a ^ b; // add without carrying
: int carry = (a & b) << 1; // carry, but don't add
: return add_no_arithm(sum, carry); // recurse
: }

1 (共1页)
进入JobHunting版参与讨论
相关主题
Ask a google interview question(2)再出一题
A Google Problem (2)这道题怎么做的?
问个题1:implement + - * / without arithmetic operationC++ 一小题
大家帮我看看我的recruiter是在帮我还是在玩我?有基础面试题么
时针和分针角度问题Google 面试
fb两轮面试,据信两封Bloomberg phone interview (intern)
这道题有没有答案呀?问道看到的面试题
这道题,怎么做呀?c++ class default functions?
相关话题的讨论汇总
话题: add话题: write话题: arithmetic话题: operator话题: without