题解 | #数组遍历#
数组遍历
https://www.nowcoder.com/practice/0f8219cb6f6e4e99a1bb0e868e51d60a
import java.util.Scanner; public class Main { public static void main(String[] args) { int[] arr = new int[6]; Scanner sc = new Scanner(System.in); for (int i = 0; i <arr.length ; i++) { arr[i]=sc.nextInt(); } int max=arr[0]; int min=arr[0]; for (int i = 1; i < arr.length; i++) { if(arr[i]>max){ max=arr[i]; } if(arr[i]<min){ min=arr[i]; } } System.out.println(max+" "+min); } }
java相关 文章被收录于专栏
java刷题,或许会有其他方面