谁能告诉我怎么回事~~~~(>_<)~~~~
/***求数组中的最大值、最小值、平均值与总和
* 2010/9/13
*/
public class Array
{
public static void main (String[] args)
{
int[]ary = new int[10];
int max = ary[0];
int min = ary[0];
int sum = 0;
int average;
for (int i = 0; i<ary.length; i++)
{
ary[i]=Integer.parseInt(args[i]);
sum = sum + ary[i];
if(ary[i]>=max)
max = ary[i];
if(ary[i]<=min) //这里有问题吗?
min = ary[i];
}
average = sum/10;
System.out.println ("最大值:"+max);
System.out.println ("最小值:"+min);
System.out.println ("平均值:"+average);
System.out.println ("总 和:"+sum);
}
}
怎么计算的最小值都是0呀,不管输入什么非0数。