usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{publicclassStudent{privatestringname;//姓名privateinteng,math,sum;//英语,数学,总成绩publicintpsum{get{returnsum;}//get访问}publicvoidinscore(){Console.Write(姓名:);name=Console.ReadLine();Console.Write(英语:);eng=int.Parse(Console.ReadLine());Console.Write(数学:);math=int.Parse(Console.ReadLine());sum=eng+math;}publicvoiddisplay(){Console.WriteLine(\t{0}\t{1}\t{2}\t{3},name,eng,math,sum);}}classProgram{constintMax=100;staticvoidsort(intn,paramsStudent[]p)//采用冒泡排序法排序{inti,j;boolA;Studenttmp;for(i=0;in-1;i++){A=false;for(j=n-2;j=i;j--)if(p[j+1].psump[j].psum){tmp=p[j+1];//p[j+1]-p[j]p[j+1]=p[j];p[j]=tmp;A=true;}if(A==false)break;}}staticvoidMain(string[]args){intn,i;Student[]p=newStudent[Max];//定义对象引用数组Console.Write(输入n个学生:);n=int.Parse(Console.ReadLine());for(i=0;in;i++)//创建对象引用的实例p[i]=newStudent();for(i=0;in;i++){Console.WriteLine(输入第{0}个学生数据:,i+1);p[i].inscore();}Console.WriteLine(排序前:);Console.WriteLine(\t姓名\t英语\t数学\t总分);for(i=0;in;i++){Console.Write(序号{0}:,i+1);p[i].display();}sort(n,p);//按总降序排序Console.WriteLine(排序后:);Console.WriteLine(\t姓名\t英语\t数学\t总分);for(i=0;in;i++){Console.Write(第{0}名:,i+1);p[i].display();}}}}