【SWUSTOJ】1001: A+B again!!
2016-05-31 00:08
1816 查看
1001: A+B again!!
Time Limit:1000MS Memory Limit:65536KBTotal Submit:50 Accepted:23 Page
View:7918
原题链接
Description
Your task is to calculate the sum of some integers.
Input
Input contains multiple test cases, and one case one line. Each case starts with an integer N( 0 < N<=500 ), and then N integers follow in the same line.
Output
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.
Sample
Input
Raw
4 1 2 3 4 5 1 2 3 4 5
Sample
Output
Raw
10 15
Hint
提供一个参考程序: C语言: #include"cstdio" ///也可以使用 < > 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; } 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; }
Source
#include<iostream> using namespace std; int main() { int n,a; while(cin>>n) {int sum=0; while(n) { cin>>a; sum+=a; n--; } cout<<sum<<endl; } return 0; }
相关文章推荐
- Grails,应该不错
- codeforces 651B Beautiful Paintings(贪心)
- 迭代器辅助函数
- Codeforces 676E The Last Fight Between Human and AI 规律
- DLL入口函数DllMain
- MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainC
- Leetcode 172. Factorial Trailing Zeroes
- LLVM example for main
- Scala中特质trait与抽象类abstract的区别
- 在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan" 可以让界面不被弹出的键盘挤上去。
- RAID磁盘阵列
- Easy-题目41:219. Contains Duplicate II
- Easy-题目32:172. Factorial Trailing Zeroes
- Only Link: Inheritance and the prototype chain
- Easy-题目18:70. Climbing Stairs
- Easy-题目10:217. Contains Duplicate
- ping www.baidu.com 不通 开启DNS
- xenomai-GNU/Linux上的RTOS模拟架构实现
- Make things beautiful again !
- Make things beautiful again !