public class Chapter5test4 {
public static void main(String[] args) {
int max=0; //最大值
int min = 0; //最小值
int num =0; //键盘输入的值 Scanner value = new Scanner(System.in);
System.out.print("请输入一个整数(输入0结束):");
max=min=num=value.nextInt();
do {
if(num>max) {
max = num;
}else if(num<min) {
min = num;
}
System.out.print("请输入一个整数(输入0结束):");
num=value.nextInt();
} while (num!=0);
System.out.println("最大值为:"+max+"\t"+"最小值为:"+min);
}
}
public static void main(String[] args) {
int max=0; //最大值
int min = 0; //最小值
int num =0; //键盘输入的值 Scanner value = new Scanner(System.in);
System.out.print("请输入一个整数(输入0结束):");
max=min=num=value.nextInt();
do {
if(num>max) {
max = num;
}else if(num<min) {
min = num;
}
System.out.print("请输入一个整数(输入0结束):");
num=value.nextInt();
} while (num!=0);
System.out.println("最大值为:"+max+"\t"+"最小值为:"+min);
}
}