public class MathRandomTest {
public static void main(String[] args) {
int MAXof100,MINof100,count=0;
int num;
MAXof100=(int)(100*Math.random());
MINof100=(int)(100*Math.random());
System.out.println(MAXof100+" ");
System.out.println(MINof100+" ");

if(MINof100>MAXof100){
num=MINof100;
MINof100=MAXof100;
MAXof100=num;
}

for(int i=0;i<98;i++){
num=(int)(100*Math.random());
System.out.print(num+((i+2)%10==9?"\n":" "));

if(num>MAXof100)
MAXof100=num;
else 
MINof100=num;

if(num>50) count++;
}
System.out.println("The MAX of 100 random integers is: "+MAXof100);
System.out.println("The MIN of 100 random integers is: "+MINof100);
System.out.println("The number of random more than 50 is: "+count);
}}

解决方案 »

  1.   

    运行你的程序了
    输出结果
    50 
    84 
    83 64 67 83 65 15 43 94
    91 29 4 50 59 73 45 67 69 43
    28 63 42 11 84 30 61 3 53 1
    43 99 46 45 73 80 61 68 52 24
    61 61 21 82 39 91 20 2 43 5
    25 33 56 43 0 80 19 42 60 8
    18 53 98 45 25 44 9 95 91 13
    42 65 32 16 90 81 61 9 13 23
    28 96 40 80 4 29 67 29 93 10
    84 51 48 18 54 11 21 56 22 81
    The MAX of 100 random integers is: 99
    The MIN of 100 random integers is: 81
    The number of random more than 50 is: 45是不是你要写出100个以内所有数字,不按照顺序显示,然后求最大值、最小值?
      

  2.   

    参考这个:http://blog.csdn.net/lihan6415151528/archive/2008/12/20/3562613.aspx
    之后排序即可,今天脑子乱,就不看你的代码了
      

  3.   


    if(num>MAXof100) 
    MAXof100=num; 
    else 
    MINof100=num; MINof100 
    如果maxof100=50
       num=55
       那maxof100=55 
       num=95
       那maxof100=95
       然后问题在这 num=90的时候 他没95大 
        不就给minof100了 
        所以不可能保持小的 你的算法设计有问题 改改吧
      

  4.   


    public class MathRandomTest { 
    public static void main(String[] args) { 
    int MAXof100,MINof100,count=0; 
    int num; 
    MAXof100=(int)(100*Math.random()); 
    MINof100=(int)(100*Math.random()); 
    System.out.println(MAXof100+" ");
    System.out.println(MINof100+" ");
    System.out.println("abc");if(MINof100>MAXof100){ 
    num=MINof100; 
    MINof100=MAXof100; 
    MAXof100=num; 
    } for(int i=0;i <98;i++){ 
    num=(int)(100*Math.random()); 
    System.out.print(num+((i+2)%10==9?"\n":" ")); if(num>MAXof100){
    if (num>MINof100){
    MAXof100=num;
    }
    }
    if(num<MAXof100){
    if(num<MINof100){
    MINof100=num;
    }
    }if(num>50) count++; } 
    System.out.println("The MAX of 100 random integers is: "+MAXof100); 
    System.out.println("The MIN of 100 random integers is: "+MINof100); 
    System.out.println("The number of random more than 50 is: "+count); } } 这样改应该可以了!
      

  5.   

    那个判断直接
    if(num>=MAXof100){ 
      MAXof100=num;
    }
    if(num<MINof100){ 
      MINof100=num; 
    }应该可以吧LZ可能想太快了吧,<MAXof100不一定就小于MINof100
      

  6.   

    if(num <MINof100)
    还有貌似都忽略判断前两个值是否大于50了;