ACM_Power Mouth
Power Mouth
Time Limit: 2000/1000ms (Java/Others)
Problem Description:
Your task is to calculate the sum of some integers.
Input:
The input contains several cases,each case contains an integer N in the first line, and then N lines follow(as a group). Each line starts with a integer M, and then M integers follow in the same line.
Output:
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.
Sample Input:
It is easy.
Sample Output:
It is simple.
解题思路:题目很简单,输出之间要有一空行,累加m个数并输出即可。
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 LL sum,n,m,x;bool flag; 5 int main(){ 6 while(cin>>n){ 7 flag=false; 8 while(n--){ 9 cin>>m;sum=0; 10 if(flag)cout<<endl;//输出之间留一空行,第一次不输出,以后每次都输出空行 11 while(m--){cin>>x;sum+=x;} 12 cout<<sum<<endl; 13 flag=true; 14 } 15 } 16 return 0; 17 }