A1.A+B problem题解[双语]
2024-09-08 13:12:02
发布于:上海
7阅读
0回复
0点赞
作者的话:
欢迎你进入C++或Python的程序世界,欢迎来到ACGO,迈出你的第一步!
分析
题目:这是一道入门题,计算a+b的和。
思路
在C++和Python中,我们都可以在输出时候直接计算,例如这样:
cout << a + b; // C++
print(a + b) # Python
用 C++ 的朋友请注意,输入前请提前定义变量;用 Python 的朋友请注意,Python 做 ACGO 的题通常来说都是需要加上.split来分隔空格的。
另外,C++ 中这题是可以用 int 类型的,我们可以看到题目里给出的数据范围是 ,最大数据也才 ,还没达到 C++ 中 int 类型的上限 ,不需要使用 long long 类型。
代码
C++
#include <iostream>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
Python
a = input().split(' ')
print(int(a[0]) + int(a[1]))
2024年09月08日 版本1
这里空空如也
有帮助,赞一个