!一iy
嗯
上午 11:21:36
yi一! 2016/10/11 星期二 上午 11:21:36
package sum.shiyan;
import java.util.Scanner;
public class MAXMIN {
private static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
System.out.println("输入五个数字:");
int [] count=new int[5];
//用数组保存输入的数字
int max=0;//定义最大值
for(int i=0;i<5;i++){
count[i]=input.nextInt();
}
for (int i = 0; i < count.length; i++) {
for (int j = 0; j < count.length; j++) {
if (count[i]<count[j]) {
max = count[j];
count[j] = count[i];
count[i] = max;
}
}
}
System.out.println("最大的数字是:"+count[count.length-1]);
System.out.println("最小的数字是:"+count[0]);
}
}