15, the structure body exercises

Source: Internet
Author: User

Specific requirements: A. The information of any student from the console is recorded with the result (student number, name, C language score) using structure B. Print the total and average scores of the class in the console, and print the highest and lowest student information for the Class C. Print the class score book and discharge the rank according to the high and low grade
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacejiegouti2{classProgram {structStudent { Public stringXuehao;  Public stringxingming;  Public decimalFenshu; }        Static voidMain (string[] args) {Console.WriteLine ("Welcome to the student score management system! "); Console.WriteLine ("Please enter the number of students"); intShu =int.            Parse (Console.ReadLine ()); Student[] Shuzu=NewStudent[shu]; decimalsum =0;  for(intm =0; M < Shu; m++) {Console.WriteLine ("Please enter the \ r number, name, C-language score for the {0} students", M +1); stringA =Console.ReadLine (); string[] B = a.split (New Char[] {'\ t' }); Shuzu[m].xuehao= b[0]; Shuzu[m].xingming= b[1]; Shuzu[m].fenshu=decimal. Parse (b[2]); Sum+=Shuzu[m].fenshu; }             for(intm =0; M < shu-1; m++)            {                 for(intn = m+1; n < Shu; n++)                {                    if(Shuzu[m].fenshu <Shuzu[n].fenshu) {Student Zhong=Newstudent (); Zhong=Shuzu[n]; Shuzu[n]=Shuzu[m]; SHUZU[M]=Zhong; }}} Console.WriteLine ("Total score is: {0}", sum); Console.WriteLine ("Average score is: {0}", Sum/Shu); Console.WriteLine ("the highest score is {2} of the name {1} of the study number {0}", shuzu[0].xuehao. ToString (), shuzu[0].xingming. ToString (), shuzu[0].fenshu.            ToString ()); Console.WriteLine ("the lowest score is the {2} of the name {0} of the study number {1}", Shuzu[shu-1].xuehao. ToString (), Shuzu[shu-1].xingming. ToString (), Shuzu[shu-1].fenshu.            ToString ()); Console.WriteLine ("descending order is: \ n rank \ t School number \ t name \ t fraction");  for(intm =0; M < Shu; m++) {Console.WriteLine ((M+1)+"\ t"+shuzu[m].xuehao +"\ t"+ shuzu[m].xingming +"\ t"+Shuzu[m].fenshu);        } console.readline (); }    }}

The effect is as follows:

15, the structure body exercises

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.