SUM

import java.util.Scanner;

public class TestScanner {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
        int nextValue,sum = 0;
        Scanner sr = new Scanner(System.in);
        sr.useDelimiter("\\s");
        while(sr.hasNextInt()){
        nextValue = sr.nextInt();
        sum += nextValue;
        }
        System.out.println("Sum = "+sum);
        sr.close();
 }
}
posted on 2016-03-30 12:29  范家铭  阅读(150)  评论(0编辑  收藏  举报