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);
}
}
时间: 2024-11-25 02:56:22