"Structure" average score and highest score

Source: Internet
Author: User

Title Description

Enter the names of 5 students in a class and their math and English scores to calculate the average score for each student, and then output the names of the students with the highest average score and the scores of maths and English.

Input requirements

Enter the names of 5 students in a class and their math and English scores. The name is a string that is not more than 19 characters in length, and the result is represented by an integer.

Output requirements

Output the name and average of each student, the average number of floating-point numbers, the output is accurate to 1 digits after the decimal point.

The names of the students with the highest average scores were then printed, as well as math and English.

If the input
AAA 88bbb 89CCC 82ddd 85 66eee 66
should be output
AAA 74.5bbb 76.0CCC 73.0ddd 75.5eee 75.5The Max SCORE:BBB 63 89
1#include <stdio.h>2 structstudent{3     Charname[ -];4     intMath;5     int中文版;6     floataverage,sum;7     };8 intMainvoid)9 {  Ten     intI,max; One     structStudent stud[5]; A       -      for(i=0;i<5; i++){ -scanf"%s",&stud[i].name); thescanf"%d",&Stud[i].math); -scanf"%d",&Stud[i]. 中文版); -stud[i].sum=stud[i].math+Stud[i]. 中文版; -Stud[i].average =stud[i].sum/2; +         } -      for(i=0;i<5; i++) +printf"%s%.1f\n", Stud[i].name, stud[i].average); A      atmax=0; -      for(i=1;i<5; i++){ -         if(stud[max].average<stud[i].average) -max=i; -     } -printf"The Max Score:%s%d%d\n", Stud[max].name, Stud[max].math, Stud[max]. 中文版); in         return 0; -}

"Structure" average score and highest 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.