Random random = new Random();
int[] arr=new int[100];
int count=0,sum=0;
for (int i = 0; i < 100; i++) {
arr[i]=random.nextInt(100)+1;
if (arr[i]%2==0) {
count++;
if (count%10!=0) {
System.out.print(arr[i]+",");
}else{
System.out.println(arr[i]);
}
sum+=arr[i];
}
}
System.out.println();
//对平均数保留两位小数
DecimalFormat decimalFormat=new DecimalFormat("####0.00");
//System.out.println(sum);
System.out.println("平均数是:"+decimalFormat.format(((double)sum/count))+
"偶数的个数为:"+count);