解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Text { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub、 Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); int [] arr=new int[n]; for (int i = 0; i < arr.length; i++) { arr[i]=scanner.nextInt(); } int max=arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i]>max) { max=arr[i]; } } int min=arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i]<min) { min=arr[i]; } } System.out.println(max+" "+min); } }
0.0分
1 人评分