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
|
import java.util.Scanner;
public class A03 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner (System.in);
System.out.println( "请输入一个整数(以0结束):" );
int num=input.nextInt();
int max=num;
int min=num;
while (num!= 0 ){
if (num>max){
max=num;
}
if (num<min){
min=num;
}
System.out.println( "请输入一个整数(以0结束):" );
num=input.nextInt();
}
System.out.println( "最大值:" +max+ "最小值:" +min);
}
} |
本文转自 Y幕徐 51CTO博客,原文链接:http://blog.51cto.com/765133133/1420494