15-07-10 structure-Enter student scores to sort

Source: Internet
Author: User

Enter each student's learning score, sorted by total score

struct Student
{
public string name;
public int age;
public double Cshap;
public double Database;
public double Html;
public double sum;
}
static void Main (string[] args)
{
    
Console.WriteLine ("Please enter the number of students:"); intA =Convert.ToInt32 (Console.ReadLine ()); List<Student> list =NewList<student>(); for(inti =0; i < A; i++) {Student s=NewStudent (); Console.WriteLine ("Please enter the name of the student {0}:", i+1); S.name=Console.ReadLine (); Console.WriteLine ("Please enter the age of the {0} students:", i +1); S.age=Convert.ToInt32 (Console.ReadLine ()); Console.WriteLine ("Please enter the CSHAP score for the {0} students:", i +1); S.cshap=convert.todouble (Console.ReadLine ()); Console.WriteLine ("Please enter the database score for the {0} students:", i +1); S.database=convert.todouble (Console.ReadLine ()); Console.WriteLine ("Please enter the page scores for the {0} students:", i +1); S.html=convert.todouble (Console.ReadLine ()); S.sum= S.cshap + S.database +s.html; List. ADD (s); } //Sort for(inti =0; I < list. count-1; i++) { for(intj =0; J < list. Count-1I J + +) { if(List[j].sum <= List[j +1].sum) {Student ZJ=List[j]; LIST[J]= List[j +1]; List[j+1] =ZJ; } } } //OutputConsole.WriteLine ("name \ t age \tcshap\t database \ t page \ Total score"); foreach(Student datainchlist) {Console.WriteLine (Data.name+"\ t"+data.age+"\ t"+data. cshap+"\ t"+data. Database+"\ t"+data. html+"\ t"+data.sum); }
}

15-07-10 structure-Enter student scores to sort

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.