输入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);
}
}
浙公网安备 33010602011771号