大三狗准备重拾ACM了,想当初大一的时候因为格式错误就放弃了ACM,那时候还真是不坚定呢,不过幸好后来也没有荒废时光吧。发现在杭电提交的代码不知道哪里可以看到,所以决定在博客里面记录下来,由于本校的oj关掉了,所以选择了杭电的oj,从第1000题开始刷,平时C和C++都有用,所以写的时候一般哪个手顺用哪个。。个人觉得第一题主要注意输入输出的格式。
Problem Description
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.
Sample Input
1 1
Sample Output
2
Submission
#include <stdio.h>
int main()
{
int a,b;
// 在while循环中以EOF作为文件结束标志
// ASCII代码值的范围是0~255,不可能出现-1,因此可以用EOF作为文件结束标志
while(scanf("%d %d",&a,&b)!=EOF){
//while (~scanf("%d%d", &x, &y))可以表示循环输入
// 输出语句
printf("%d\n",(a+b));
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<<a+b<<endl;
}
return 0;
}