在CSDN看到的“不用加号”的方法

P1001 A+B Problem

@[Flokirie](/space/show?uid=51001) $\tan\frac{\pi}{2}$
by 老K @ 2018-01-03 15:36:49


@[Flokirie](/space/show?uid=51001) tan90°
by 老K @ 2018-01-03 15:37:31


```cpp #include<bits/stdc++.h> using namespace std; int main() { int x,y; cin>>x>>y; cout<<(x&y)+(x|y); return 0; } ```
by bcku1 @ 2018-01-08 14:15:58


@[Dog\_Two](/space/show?uid=38283)
by bcku1 @ 2018-01-08 14:16:09


@[bcku1](/space/show?uid=19980) 您这还是用到加号了呀
by Dog_Two @ 2018-01-08 16:58:39


```c #include<iostream> using namespace std; int fun(int x,int y){ if(y==0) return x; return fun(x^y,(x&y)<<1); } int main(){ int a,b; cin>>a>>b; cout<<fun(a,b)<<endl; return 0; } ```
by ZqlwMatt @ 2018-01-22 18:57:32


一样
by ZqlwMatt @ 2018-01-22 18:58:09


```cpp #include <cstdio> using namespace std; int add(int a, int b) { if(b) { if(b>0) { return add(-~a,~-b); } else { return add(~-a,-~b); } } else { return a; } } int main() { int a,b; scanf("%d%d",&a,&b); printf("%d",add(a,b)); } ```
by 木木! @ 2018-02-06 17:52:48


pascal可以用inc
by 长河落日 @ 2018-02-10 14:44:42


问dalao,dalao告诉我的做法:```cpp #include<iostream> using namespace std; int main(){ long long a,b; cin>>a>>b; b=-b; cout<<a-b; return 0; } ```
by 长河落日 @ 2018-02-10 15:34:43


上一页 | 下一页