大三狗準備重拾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;
}