6.17 Review the bubble sort of student information based on student score

Source: Internet
Author: User

usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceReview cs{classProgram {structStudent { Public intnum;  Public stringCode;  Public stringName;  Public decimalscore; }        Static voidMain (string[] args) {            //1. Loop to add student informationArrayList list =NewArrayList ();  for(inti =1; I <4; i++) {Student s=NewStudent ();//instantiation ofConsole.Write ("Please enter section"+ i +"Student's School number:"); S.code=Console.ReadLine (); Console.Write ("Please enter section"+ i +"the name of a student:"); S.name=Console.ReadLine (); Console.Write ("Please enter section"+ i +"A student's achievement:"); S.score=Convert.todecimal (Console.ReadLine ()); S.num=i; List.                ADD (s); Console.WriteLine ("==============================="); } Console.WriteLine ("-----------------------student data show--------------------------"); //2. Sorting             for(inti =0; I < list. Count-1; i++)            {                 for(intj = i +1; J < list. Count; J + +) {Student S1=(Student) list[i]; Student S2=(Student) list[j]; if(S1. Score <S2. Score) {Object ob=List[i]; List[i]=List[j]; LIST[J]=ob; }                }            }            //3. Printing            foreach(ObjectOinchlist) {Student SS=(Student) o; Console.WriteLine ("Section"+ Ss.num +"Student's School number:"+ SS. Code +", Name:"+ SS. Name +", Score:"+ SS. Score +". ");        } console.readkey (); }    }}

6.17 Review the bubble sort of student information based on student score

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.