【SWUSTOJ】OJ解析(自用
1001: A+B again!!
c++:
#include<iostream>
using namespace std;
int main()
{
int n,x,sum;
while(cin >> n)
{
sum = 0;
while(n--)
{
cin >> x;
sum += x;
}
cout << sum << endl;
}
return 0;
}
c
#include<stdio.h>
int main()
{
int n,x,sum;
while(scanf("%d", &n) != EOF) /// EOF: end of file 文件结束标志
{
sum = 0;
while(n--)
{
scanf("%d", &x);
sum += x;
}
printf("%d\n", sum);
}
return 0;
}