Description |
从键盘读取一组正整数,输出这组正整数的累加和.其中第一个数为这组数的个数. |
Input |
输入一组正整数,其中第一个数为这组数的个数,各数之间用空格隔开。 |
Output |
这组正整数的累加和。 |
Sample Input |
5 1 3 4 6 1 3 2 4 6 |
Sample Output |
15 12 |
package Main;
import java.util.Scanner;
public class Main {
public static void main(String args[])
{
long count = 0;
int b;
int i;
Scanner input = new Scanner(System.in);
while(input.hasNext()){
int n = input.nextInt();
count=0;
for(i=0;i<n;i++)
{
b=input.nextInt();
count+=b;
}
System.out.println(count);
}
}
}