import javax.swing.JOptionPane;
public class FenShu{
public static void main(String args[]){
FenShu aaa=new FenShu();
String n1,n2;
int gs,average,sum=0;
n1=JOptionPane.showInputDialog("请输入人数:");
gs=Integer.parseInt(n1);
int fs[]=new int[gs];
for(int j=0;j<gs;j++)
{n2=JOptionPane.showInputDialog("输入第"+(j+1)+"分数");
fs[j]=Integer.parseInt(n2);
}
//排训
// System.out.print("!!!!!!!!!!!!") ;
for(int o = fs.length - 1; o >= 0; o--)
{
for(int k = 0,temp; k < o; k++)
{
if(fs[k]>fs[k+1])
{ temp=fs[k];
fs[k]=fs[k+1];
fs[k+1]=temp;}
}
}
for(int w=0;w<fs.length;w++){
sum+=fs[w];}
average=sum/gs;
//输出
String output="总分数为"+" "+sum+"平均分为 "+average+"排序是:";
for(int w=0;w<fs.length;w++)
output+=fs[w]+" ";
JOptionPane.showMessageDialog(null,output,"结果",JOptionPane.PLAIN_MESSAGE);
}
}
评论