1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Collections;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceConsoleApplication19 {Ten class Program One { A structStudent//Structural Body - { - Public intXuhao; the Public stringXuehao;//School Number - Public stringName//name - Public decimalFenshu;//score - + } - Static voidMain (string[] args) + { A //Add 5 Student information to the collection, at //Each student has: study number, name, score, 3 content - //The students ' scores are arranged from high to low and printed out after the completion of the addition. - - //Please enter the 1th student's school number: 101 - //Please enter the name of the 1th student: XXX - //Please enter the 1th student's grade: in //------------------------(note add a split line) - //Please enter the 2nd Student's School number: 102 to //Please enter the name of the 2nd student: XXX + //Please enter the 2nd student's score: 98 - //.... Until the 5th entry is complete, then press ENTER the //1th Student Number: 101, Name: XXX: Score: * //a 2nd student .... $ //3rd one.Panax Notoginseng //add a split line to each segment - the //1. Loop to add student information +ArrayList list =NewArrayList (); A the for(inti =1; I <6; i++) + { -Student Stu =NewStudent ();//instantiation of $ $Console.Write ("Please enter section"+ i +"Student's School number:"); -Stu.xuehao =console.readline (); -Console.Write ("Please enter section"+ i +"the name of a student:"); theStu.name =console.readline (); -Console.Write ("Please enter section"+ i +"A student's achievement:");WuyiStu.fenshu =Convert.todecimal (Console.ReadLine ()); theStu.xuhao =i; - Wu list. ADD (Stu); -Console.WriteLine ("==============================="); About } $ -Console.WriteLine ("------------------------Ranking--------------------------"); - - //2. Sorting A + for(inti =0; I < list. Count-1; i++) the { - for(intj = i +1; J < list. Count; J + +) $ { theStudent STU1 =(student) list[i]; theStudent STU2 =(student) list[j]; the the if(Stu1.fenshu <Stu2.fenshu) - { inObject OB =List[i]; theList[i] =List[j]; theLIST[J] =ob; About } the } the } the + //3. Printing - foreach(ObjectOinchlist) the {BayiStudent SS =(student) O; theConsole.WriteLine ("Section"+ Ss.xuhao +"Student's School number:"+ Ss.xuehao +", Name:"+ Ss.name +", Score:"+ Ss.fenshu +". "); the } - - the the the console.readline (); the - the } the } the}
C # review-1