WA3个,正经A+B

P1001 A+B Problem

GODTREE @ 2023-08-10 17:31:18

#include <bits/stdc++.h>
#define begin {
#define end }
#define show_value return
int add (int a,int b )
begin
    show_value (a & b) << 1 + (a ^ b);
end
int input()
begin
    int n;
    scanf("%d",&n);
    return n;
end
int output(int n)
begin
    printf("%d",n);
end
int main()
begin
    int a,b;
    a=input();
    b=input();
    output(add(a,b));
    show_value 0;
end

by CuteChat @ 2023-08-10 17:34:41

7+8=0(确信


by GODTREE @ 2023-08-10 17:35:42

emmmm 加法真的好难


by juruo_zxt @ 2023-08-10 17:37:24

敌方妄图使用钓鱼岛,必须给予打击


by _Adolf_Hitler_ @ 2023-08-10 17:39:38

@GODTREE 你比他好多了(违规紫衫)


by GODTREE @ 2023-08-10 17:41:35

@JODAN_POOLE 这人好……(本人已死)


by iamzq @ 2023-08-10 17:56:23

@GODTREE 加法优先级比左移高,所以会先算加法再算左移(


by GODTREE @ 2023-08-10 18:00:16

@iamzq thank you


by Tanleyan @ 2023-08-19 16:47:42

咋都这么麻烦啊,附上超简代码,绝对AC


#include<cstdio>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    c=a+b;
    printf("%d",c);
    return 0;
}

by jinitaimei54188 @ 2023-08-20 21:11:45

@ouyangluoxi 还有更简单的吗?

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    cout<<n+m<<endl;
    return 0;
}

by Algorithm_ZRF @ 2023-08-29 15:50:04

@jinitaimei54188 不用加endl


| 下一页