偶上面写的忘记排序了
import java.io.*;
import java.util.Arrays;
public class Average
{
public static void main(String args[])
{
int sum=0,i=0,len=0;
int a[]=new int[20];
String s=null;
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(\"Please input the nums:\");
while((s=br.readLine())!=null)
{
if(Integer.parseInt(s)==-1) break;
a[i]=Integer.parseInt(s);
i++;
}
len=i;
int b[]=new int[len];
for(i=0;i<len;i++) b[i]=a[i];
Arrays.sort(b);
System.out.print(\" Asc:\");
for(i=0;i<len;i++)
{System.out.print(b[i]+\" \");
sum+=b[i];
}
System.out.print(\"\nDesc:\");
for(i=len-1;i>-1;i--) System.out.print(b[i]+\" \");
}
catch(Exception e) {}
System.out.println(\"\nThe average is:\"+sum*1.0/len);
}
}