hdu 1096 A+B for Input-Output Practice (VIII)
2016-05-22 22:51
786 查看
A+B for Input-Output Practice (VIII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 135986 Accepted Submission(s): 41510[align=left]Problem Description[/align]
Your task is to calculate the sum of some integers.
[align=left]Input[/align]
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.
[align=left]Output[/align]
For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.
[align=left]Sample Input[/align]
3 4 1 2 3 4
5 1 2 3 4 5
3 1 2 3
[align=left]Sample Output[/align]
10
15
6
#include <iostream> using namespace std; int main() { int test; int a, b; cin >> test; while(test--) { int sum = 0; int temp, n; cin >> n; for(int i = 0; i < n; i++) { cin >> temp; sum += temp; } if(test != 0) cout << sum << endl << endl; else cout << sum << endl; } return 0; }
View Code
相关文章推荐
- hdu 1095 A+B for Input-Output Practice (VII)
- PHP数据库连接mysql与mysqli的区别与用法
- thinkphp集成系列之阿里云oss
- thinkphp集成系列之阿里云oss
- thinkphp集成系列之rbac的升级版auth权限管理系统demo
- PHP开发者常犯的10个MySQL错误
- thinkphp集成系列之rbac的升级版auth权限管理系统demo
- thinkphp集成系列之rbac的升级版auth权限管理系统demo
- thinkphp集成系列之短信验证码、订单通知
- thinkphp集成系列之短信验证码、订单通知
- hdu 1094 A+B for Input-Output Practice (VI)
- thinkphp集成系列之短信验证码、订单通知
- hdu 1093 A+B for Input-Output Practice (V)
- hdu 1092 A+B for Input-Output Practice (IV)
- php类型转换
- 手机抓包总发现东北大学IP,你需要知道的NTP服务器
- Spark多文件输出(MultipleOutputFormat)
- 【php】json对象解码为array数组
- 9——PHP循环结构foreach用法
- laravel 5.1 源码阅读