第2个回答 2009-09-27
import java.util.Random;
public class Test {
public static void main(String[] args) {
int[] nums=new int[200];
int aCount=0;
int bCount=0;
for(int i=0;i<nums.length;i++){
if(i!=0&&i%10==0){
System.out.println();
}
nums[i]=new Random().nextInt(899)+100;
System.out.print(nums[i]+"\t");
if(nums[i]%2==0){
aCount++;
}else{
bCount++;
}
}
System.out.println();
System.out.println("偶数有:"+aCount+"个\t概率是:"+aCount/200.0*100+"%");
System.out.println("奇数有:"+bCount+"个\t概率是:"+bCount/200.0*100+"%");
}
}