参考代码:
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class 最大最小值 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //1918: [蓝桥杯][算法提高VIP]最大最小值 Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); int [] a=new int[n]; for (int i = 0; i < a.length; i++) { a[i]=scanner.nextInt(); } Arrays.sort(a); System.out.println(a[a.length-1]+" "+a[0]); } }
0.0分
1 人评分