#include <iostream>
#include <string>
using namespace std;
int main()
{
int n;//读入n个学生;
cin>>n;
string maxname;
string maxnumber;
int maxgrade=0;
string minname;
string minnumber;
int mingrade=0;
for(int i=0;i<n;i++)
{
string name;
string number;
int grade;
cin>>name>>number>>grade;
if(i==0)
{
maxname=name;
minname=name;
maxgrade=grade;
mingrade=grade;
maxnumber=number;
minnumber=number;
}
if(grade>maxgrade)
{
maxname=name;
maxnumber=number;
maxgrade=grade;
}
if(grade<mingrade)
{
mingrade=grade;
minnumber=number;
minname=name;
}
}
cout<<maxname<<" "<<maxnumber<<endl;
cout<<minname<<" "<<minnumber<<endl;
return 0;
}
i=0时先输入第一组数据初始化
之后每一轮都和最大最小值对比,根据结果更新maxname和maxnumber。