*1000题目
Calculate A + B.
Input
Each line will contain two integers A and B. Process to end of file.
Output
For each case, output A + B in one line
*解答:
错误:
#include <iostream>
using namespace std;
int main()
{
float a,b;
cin>>a>>b
cout<<(a+b);
return 0;
}
正确:
#include <iostream>
using namespace std;
int main()
{
float a,b;
while(cin>>a>>b)
{
cout<<(a+b)<<endl;
}
return 0;
}
本人初学者
所以在1000题上就遇上了不少问题,如下
1.oj各种类型的错误提示
2.对于题目的理解
3.具体问题
一、
(这里是一个关于常见oj问题的链接,题主写的很好 https://www.cnblogs.com/madonion/articles/2271913.html)
presentation error:格式错误
(这里是一个关于presentation error的一些想法,这个题主po的也很细致,分析了很多自己的问题
https://jingyan.baidu.com/article/29697b913e1e2aab20de3c0d.html)
在此题中,这个部分如果少了一个换行,就会有presentation error,所以在输出时要注意,其次,c++和c有不同的输出特点
while(cin>>a>>b)
{
cout<<(a+b)<<endl;
}
二、对于题目的理解
Each line will contain two integers A and B. Process to end of file.
题目中说明了每行两个数据,但并没有说明多少行。这种情况换一种常用说法叫:“多组数据”,是常见的要求。
有关多组数据