本帖最后由 徐升2013 于 2013-3-12 11:38 编辑
class Array
{
static void count(int a[])
{
int max = a[0] ;
int min = a[0];
for(int i = 0;i<a.length;i++)
{
if (a>max)
max = a;
if(a<min)
min= a;
}
System.out.println("数组中最大的值是:"+max);
System.out.println("数组中最小的值是:"+min);
}
}
public class Testarray
{
public static void main(String args[])
{
int a [] ={321,2324,545,6565,7657,2,21,34,-21,43,5465,2,1546,-312};
Array.count(a);
}
}
|