public static void main(String[] args) {
int num[] ={3,29,33,6,90,24,50};
int max = num[0];
int min = num[0];
for (int i = 0; i < num.length; i++) {
if (num > max) {
max= num;
}
if (num < min) {
min = num;
}
}
System.out.println("数组中的最大值为:" + max);
System.out.println("数组中的最小值为:" + min);
} |
|