//求最小、最大、平均、和
public void test(int[] par) {
int min=par[0],max=par[0],sum=0,ave=0;
for(int i=0;i
min = par[i];
if(max
sum = sum + par[i];
}
ave = sum/par.length;
System.out.println("最小数:" + min);
System.out.println("最大数:" + max);
System.out.println("平均数:" + ave);
System.out.println("和:" + sum);
}
测试程序:
public void test(){
ArrayTest t = new ArrayTest();
int[] i = {1,2,3,4,5,6,7,8,31,12,5,36,54,5,753,42,4,231,34,22,3};
t.test(i);
}