package cn.zxj.com;
import java.util.Scanner;
class Test {
public static void main(String[] args) {
int[] arr = input();
maximum(arr);
}
private static void maximum(int[] arr) {
for(int i = 0;i
for(int j=0;j
int temp;
if(arr[j]>arr[j+1]){
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
int max = arr[arr.length-1];
int min = arr[0];
System.out.println("最大值:"+max);
System.out.println("最小值:"+min);
}
private static int[] input() {
Scanner scanner = new Scanner(System.in);
int[] arr = new int[3];
for(int i = 0;i<3;i++){
System.out.println("请录入数字!");
int value = scanner.nextInt();
arr[i] = value;
}
return arr;
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)