最大最小值得判断代码
import java.util.Scanner;
public class Test12 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] news = new int[5];
int max = 0;
int min = 0;
for (int i = 0; i < news.length; i++) {
System.out.println("请输入" + (i + 1) + "个数:");
news[i] = input.nextInt();
}
max = news[0];
min = news[0];
for (int i = 0; i < news.length; i++) {
if (news[i] > max) {
max = news[i];
}
}
for (int i = 0; i < news.length; i++) {
if (news[i] < min) {
min = news[i];
}
}
System.out.println("max=" + max);
System.out.println("min=" + min);
}
}