遍历一次数组找到最大最小值
简单编程题
public static void main(String[] args) {
int[] numbers = {18,6,37,21,12,63,45,88,3,121,73};
int max = numbers[0];
int min = numbers[0];
for(int i=1;i<numbers.length;i++){
if(numbers[i] > max){
max = numbers[i];
}
if(numbers[i] < min){
min = numbers[i];
}
}
System.out.println("最大值:" + max + ",最小值:" + min);
}