C # review-1

Source: Internet
Author: User

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

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.