由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++ Q110: Add without +
相关主题
有个SB interviewer和我说++i比i++好 (转载)a C++ interview question..........
请教一道c/c++题C++格式输出
printf("%s\n", NULL)的结果Overridden function will cause function shadow in C++, but not in Java
10个包子请教一个简单的编程问题c++ 中如何把str转换为float?
set operation in ctwo general C++ question
C/C++函数调用和栈内存问一个C++下的Bug(Linux下)
请问c++为什么会编译失败?[合集] 这段C++程序哪种写法是正确的
谁来解释一下这个是compiler问题吗?G++用-g和-O3编译运行结果竟然不一样
相关话题的讨论汇总
话题: add话题: int话题: c++话题: q110话题: scanf
进入Programming版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
Write a function to add two numbers, without using any arithmetic operator.
X****r
发帖数: 3557
2
There is really not much point for posting this question here.
The answers are just one Google away.

【在 c**********e 的大作中提到】
: Write a function to add two numbers, without using any arithmetic operator.
S*********g
发帖数: 5298
3
xentar今天thrust附身啦

【在 X****r 的大作中提到】
: There is really not much point for posting this question here.
: The answers are just one Google away.

r****t
发帖数: 10904
4
这个狗出来的感觉很难啊。要是面的时候我就回答 accumulate/ plus

【在 X****r 的大作中提到】
: There is really not much point for posting this question here.
: The answers are just one Google away.

d****n
发帖数: 1637
5
我也以为是那个家伙呢, 一看id不是。哈哈

【在 S*********g 的大作中提到】
: xentar今天thrust附身啦
d****n
发帖数: 1637
6
狗来的:
#include
int add(int a, int b)
{
if (!a)
return b;
else
return add((a & b) << 1, a ^ b);
}
int main()
{
unsigned int a,b;
printf("Enter the two numbers: \n");
scanf("%d",&a);
scanf("%d",&b);
printf("Sum is: %d",add(a,b));
}


【在 r****t 的大作中提到】
: 这个狗出来的感觉很难啊。要是面的时候我就回答 accumulate/ plus
p*********t
发帖数: 2690
7
老考bitwise operators有意思吗? 那个字有几种写法就那么有意思?

【在 c**********e 的大作中提到】
: Write a function to add two numbers, without using any arithmetic operator.
t****t
发帖数: 6806
8
对C++来说, 这问得是没什么意思
对硬件工程师来说, 这个属于常识, 也有更复杂的算法基于这个东西.

【在 p*********t 的大作中提到】
: 老考bitwise operators有意思吗? 那个字有几种写法就那么有意思?
p*********t
发帖数: 2690
9
这其实就是 逻辑设计 里面的 与非,或非 什么的.很少用到的东西.

【在 t****t 的大作中提到】
: 对C++来说, 这问得是没什么意思
: 对硬件工程师来说, 这个属于常识, 也有更复杂的算法基于这个东西.

c****p
发帖数: 6474
10
用逻辑运算?

【在 c**********e 的大作中提到】
: Write a function to add two numbers, without using any arithmetic operator.
1 (共1页)
进入Programming版参与讨论
相关主题
G++用-g和-O3编译运行结果竟然不一样set operation in c
[合集] 一道C++面试题 (转载)C/C++函数调用和栈内存
question on divide by zero 请问c++为什么会编译失败?
A helloworld OpenMP question?谁来解释一下这个是compiler问题吗?
有个SB interviewer和我说++i比i++好 (转载)a C++ interview question..........
请教一道c/c++题C++格式输出
printf("%s\n", NULL)的结果Overridden function will cause function shadow in C++, but not in Java
10个包子请教一个简单的编程问题c++ 中如何把str转换为float?
相关话题的讨论汇总
话题: add话题: int话题: c++话题: q110话题: scanf