1004. Ranking of achievements (20)

Source: Internet
Author: User

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

IDEA: typedef structure, simple basic sorting problem
#include <iostream>#include<algorithm>using namespacestd; typedefstruct {     stringStu_name; stringstu_id; intStu_score;  }stu; intMain () {intN; CIN>>N;     Stu Max_stu,min_stu; Max_stu.stu_score= -1; Min_stu.stu_score=101;  for(intI=0; i<n; i++) {Stuinch; CIN>>inch. Stu_name; CIN>>inch. stu_id; CIN>>inch. Stu_score; if(inch. Stu_score >Max_stu.stu_score) {Max_stu.stu_name=inch. Stu_name; max_stu.stu_id=inch. stu_id; Max_stu.stu_score=inch. Stu_score; }         if(inch. Stu_score <Min_stu.stu_score) {Min_stu.stu_name=inch. Stu_name; min_stu.stu_id=inch. stu_id; Min_stu.stu_score=inch. Stu_score; }//printf ("-------------------inscore=:%d,minscore=:%d,maxscore=:%d\n", In.stu_score,min_stu.stu_score,max_ Stu.stu_score);} cout<<max_Stu.stu_Name<<" "<<max_Stu.stu_Id<<Endl; cout<<min_Stu.stu_Name<<" "<<min_Stu.stu_Id<<Endl; return 0; } 

1004. Ranking of achievements (20)

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.