1 import java.util.Scanner;//导入 2 3 public class chengji { 4 5 public static void main(String[] args) { 6 7 int rs=0; 8 Scanner arr=new Scanner(System.in);//初始化扫描器 9 10 System.out.println("请输入班级人数:"); 11 12 rs=arr.nextInt();//接受,等待输入,回车结束,返回字符串 13 14 double c[]=new double [rs];//rs数组长度 15 16 System.out.println("请输入成绩:"); 17 18 Scanner ar=new Scanner(System.in); 19 20 double sum =0; 21 for (int i=0;i<c.length;i++) 22 { 23 c[i]=ar.nextDouble();//接受扫描数据 24 25 sum+=c[i]; 26 } 27 System.out.println("成绩总和:"+sum); 28 29 for (int j=0; j<c.length;j++) 30 for(int i=0;i<c.length-1-j;i++){ 31 if(c[i]>c[i+1]){ 32 double x=c[i]; 33 c[i]=c[i+1]; 34 c[i+1]=c[i]; 35 } 36 37 } 38 System.out.println("输出最高成绩:"+c[c.length-1]); 39 40 System.out.println("输出最低成绩:"+c[0]); 41 42 System.out.println("输出平均成绩:"+sum/c.length); 43 } 44 45 46 }