1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package com.ww.yzpB;
public class maxMin {
public void MaxMin( int [] number) {
int max =number[ 0 ];
for ( int i = 0 ; i < number.length; i++) {
if (number[i]>max){
max=number[i];
}
}
int min=number[ 0 ];
for ( int i = 0 ; i < number.length; i++) {
if (number[i]<min){
min=number[i];
}
}
System.out.println( "\n最大值:" +max+ "最小值:" +min);
}
} package com.ww.yzpB;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
maxMin maxmin = new maxMin();
int rondom [] = new int [ 10 ];
System.out.print( "10个随机数为:" );
for ( int i = 0 ; i < rondom.length; i++) {
rondom[i]=( int )(Math.random()* 1000 );
System.out.print(rondom[i]+ " " );
}
maxmin.MaxMin(rondom);
}
} |
本文转自 Y幕徐 51CTO博客,原文链接:http://blog.51cto.com/765133133/1427432