Rejudge Progress:

1015: A+B for Input-Output Practice 2

Time Limit: 1000 MS Memory Limit: 65536 KB
Total Submit: 2059 Accepted: 1108 Page View: 4400
Submit Status Discuss
Your task is to calculate the sum of some integers.
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.
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.
3 4 1 2 3 4 5 1 2 3 4 5 3 1 2 3
10 15 6
提供一个参考程序: C语言: #include"cstdio" ///也可以使用 < > int main() { int testcases; int n,x,sum; scanf("%d", &testcases); while(testcases--) { scanf("%d", &n); sum = 0; while(n--) { scanf("%d", &x); sum += x; } printf("%d\n", sum); printf("\n"); } return 0; } C++: #include"iostream" ///也可以使用 < > using namespace std; int main() { int testcases; int n,x,sum; cin >> testcases; while(testcases--) { cin >> n; sum = 0; while(n--) { cin >> x; sum += x; } cout << sum << endl; cout << endl; } return 0; }