PAT (Basic level) practise 1004. Score Rankings

Source: Internet
Author: User

1004. Performance ranking time limit: Ms Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Yue

Read the names, student numbers and grades of n students, respectively, and output the highest and lowest grade students ' names and school numbers.

input Format: each test input contains 1 test cases in the format

  Line 1th: Positive integer n  2nd line: 1th Student's name School number results  3rd line: 2nd Student's name study number score  ... Line n+1: Nth Student's name number score
Where both the name and the school number are not more than 10 characters of the string, the score is an integer between 0 and 100, which guarantees that no two students in a set of test cases have the same results.

output format: output 2 lines for each test case, the 1th line is the highest grade student's name and school number, the 2nd line is the lowest grade student's name and school number, there are 1 spaces between the strings.

Input Sample:
3Joe Math990112 89Mike CS991301 100Mary EE990830 95
Sample output:
Mike Cs991301joe Math990112
1#include <iostream>2 3 using namespacestd;4 5 intMain ()6 {7     intn=0, i=0, ma=0, mi= Max, mah=0, mih=0;8     structstu{9     Charname[ -];Ten     Charnum[ -]; One     intscore; A}stud[ -]; -Cin>>N; -      for(; i<n;i++) the     { -Cin>>Stud[i].name; -Cin>>Stud[i].num; -Cin>>Stud[i].score; +         if(STUD[I].SCORE&GT;MA) {ma=stud[i].score;mah=i;} -         if(STUD[I].SCORE&LT;MI) {mi=stud[i].score;mih=i;} +     } Acout<<Stud[mah].name; atcout<<" "; -cout<<Stud[mah].num; -cout<<"\ n"; -cout<<Stud[mih].name; -cout<<" "; -cout<<Stud[mih].num; in  -     return 0; to}

PAT (Basic level) practise 1004. Score Rankings

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.