展开全部
java编写程序,找出一维数组中元素的32313133353236313431303231363533e58685e5aeb931333337393033最大值和最小值:
方法1:import java.util.*;
public class Main{
public static void main (String args[ ]) {
int a1[ ]=new int[] {5,3,6,8,10,56};
Arrays.sort(a1);
System.out.println("最大值:"+a1[a1.length-1]);
System.out.println("最小值:"+a1[0]);
}
}
方法2:public class a {
public static void main(String args[]) {
int a[]={84,40,16,3,10,49,28,76,94,70};
int n;
int min=a[0];
int i;
int max=a[0];
for(n=0;n<=9;n++) {
if(max
max=a[n];
}
for(i=0;i<=9;i++) {
if(min>a)
min=a;
}
System.out.print("max="+max);
System.out.print("min="+min);
}
}