标签:
import java.util.Scanner;
public class Sum {
public static void main(String[] args) {
// TODO Auto-generated method stub
int nextValue, sum=0;
Scanner sc = new Scanner(System.in);
sc.useDelimiter("\s");
while(sc.hasNextInt())
{
nextValue = sc.nextInt();//读取从键盘输入的数
sum += nextValue;
}
sc.close();
System.out.println("Sum:" + sum);
System.out.printf("Sum: %d",sum);
}
}
标签:
原文地址:http://www.cnblogs.com/wanke/p/5499828.html