输入n个整数,输出其乘积的java代码

import java.util.*;
public class Example2{
    public static void main (String args[ ]){
       Scanner reader=new Scanner(System.in);
       int product=1;
       int n=0;
       while(reader.hasNextInt()){
           int x=reader.nextInt();
           n=n+1;
           product=product*x;
       }
       System.out.printf("%d个数的积为%f\n",n,product);
    }
}

posted on 2013-03-11 18:49  jixiuyan  阅读(800)  评论(0)    收藏  举报