C # Review Questions

Source: Internet
Author: User

C # review:
Problem:
Add 5 Student information to the collection,
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.

 1   Define a set of variables in other classes  2  3  4  class   student  5   { 6  public  string   code;  7  public  string   name;  8  public  decimal   score;  9 } 
1ArrayList ary =NewArrayList ();2              for(inti =1; I <6; i++)3             {4Student S =Newstudent ();5Console.Write ("Please enter section"+ i +"Student's School number:");6S.code =console.readline ();7Console.Write ("Please enter section"+ i +"the name of a student:");8S.name =console.readline ();9Console.Write ("Please enter section"+ i +"A student's achievement:");TenS.score =decimal. Parse (Console.ReadLine ()); One ary. ADD (s); AConsole.WriteLine ("-----------------------------------------------------"); - Console.Write (s.score); -             } the              for(inti =0; i < ary. Count; i++) -             { -                  for(intL = i +1; L < ary. Count; l++) -                 { +Student S1 =(student) ary[i]; -Student S2 =(student) ary[l]; +                     if(S1.score <S2.score) A                     { at                         ObjectZhong =Ary[i]; -Ary[i] =Ary[l]; -ARY[L] =Zhong; -                     } -                 } -             } in             foreach(ObjectOinchary) -             { toStudent oo =(student) O; +Console.WriteLine (oo.code+"\ t"+oo.name+"\ t"+oo.score); -}

C # Review Questions

Related Article

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.