usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Collections;namespaceconsoleapplication1{classProgram {structStudent { Public intCode//PU modifier blic Public stringName//struct Members Public intShengao; } Static voidMain (string[] args) { //structure, user-defined data types, variable groups, you can save multiple data variables at once, defined outside the main function, class inside//Title: Define a student's structure, school number, name, height, and enter student information. Sort output by HeightArrayList Al =NewArrayList ();//Defining Collections//Input Collection for(inti =1; I <=Ten; i++) {student S=Newstudent (); Console.Write ("Please enter the school number"); S.code=int. Parse (Console.ReadLine ()); Console.Write ("Please enter your name"); S.name=Console.ReadLine (); Console.Write ("Please enter height cm"); S.shengao=int. Parse (Console.ReadLine ()); Al. ADD (s); } //Bubble Sort for(inti =0; I <9; i++) { for(intj = i +1; J <Ten; J + +) {Student Si=(student) al[i]; Student SJ=(student) al[j]; if(Si.shengao <Sj.shengao) {Student Zhong=si; Al[i]=Al[j]; AL[J]=Zhong; } } } //iterating through the collection foreach(Student Sinchal) {Console.WriteLine (S.code+" "+ S.name +" "+S.shengao); } console.readline (); } }}
Define a student's structure, school number, name, height, and enter student information. Sort by height output