/** * Created by xabcd on 2019/2/13. */ public class Java_maxmin {public static void main(String args[]) { int i,max,min; int A[]={74,48,30,17,62}; min = max = A[0]; System.out.print("数组A包含的元素包括:"); for (i = 0;i<A.length;i++) {System.out.println(A[i]+" "); if (A[i]>max) max = A[i]; if (A[i]<min) min = A[i]; } System.out.println("最大值"+max); System.out.println("最小值"+min); } }
/** * Created by xabcd on 2019/2/13. */ public class Java_maxmin {public static void main(String args[]) { int i,max,min; int A[]={74,48,30,17,62}; min = max = A[0]; System.out.print("数组A包含的元素包括:"); for (i = 0;i<A.length;i++) {System.out.println(A[i]+" "); if (A[i]>max) max = A[i]; if (A[i]<min) min = A[i]; } System.out.println("最大值"+max); System.out.println("最小值"+min); } }
数组A包含的元素包括:74
48
30
17
62
最大值74
最小值17
Process finished with exit code 0