pat-Grade B-1004 rankings

Source: Internet
Author: User

Read n (>) students ' names, school numbers, and grades, respectively, and the names and student numbers of the students with the highest and lowest grades.

Input Format:

Each test input contains 1 test cases in the form

第 1 行:正整数 n第 2 行:第 1 个学生的姓名 学号 成绩第 3 行:第 2 个学生的姓名 学号 成绩  ... ... ...第 n+1 行:第 n 个学生的姓名 学号 成绩

where 姓名 and 学号 both 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, the string has 1 spaces.

Input Sample:
3Joe Math990112 89Mike CS991301 100Mary EE990830 95
Sample output:
Mike CS991301Joe Math990112


Analysis:
C + + Write a structure can
Python can write a simple class


1 //C + +2#include <iostream>3 using namespacestd;4 5typedefstructXXX6 {7   Charname[ the];8   Charnum[ the];9   intscore;Ten }infor; One intMain () A { -   intN; -Cin>>N; the     if(!N) -       return 0; -Infor *inf; -INF =NewInfor[n]; +   intMax,min,maxn,minn; -maxn=minn=0; +Max =0; min = -; A    for(intI=0; i<n;i++) at   { -Cin>>inf[i].name>>inf[i].num>>Inf[i].score; -     if(Max <Inf[i].score) -     { -Max =Inf[i].score; -MAXN =i; in     } -     if(Min >Inf[i].score) to     { +Min =Inf[i].score; -Minn =i; the     } *   } $cout<<inf[maxn].name<<' '<<inf[maxn].num<<Endl;Panax Notoginsengcout<<inf[minn].name<<' '<<inf[minn].num<<Endl; -    the   return 0; +}

pat-Grade B-1004 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.