C
#include <stdio.h>
struct Student{
char name[11];
char id[11];
int score;
}temp, stuMax, stuMin;
int main()
{
int n;
scanf("%d",&n);
stuMax.score = 0;
stuMin.score = 100;
for(int i=0; i<n; i++)
{
scanf("%s %s %d",&temp.name,&temp.id,&temp.score);
if(temp.score>stuMax.score) stuMax=temp;
if(temp.score<stuMin.score) stuMin=temp;
}
printf("%s %s\n",stuMax.name,stuMax.id);
printf("%s %s\n",stuMin.name,stuMin.id);
return 0;
}
C++
#include <iostream>
using namespace std;
void fun(int n)
{
int max=0,min=100,score=0;
string maxName, maxId;
string minName, minId;
string name, id;
for(int i=0; i<n; i++)
{
cin >> name >> id >> score;
if(score>max)
{
maxName = name;
maxId = id;
max = score;
}
if(score<min)
{
minName = name;
minId = id;
min = score;
}
}
cout << maxName << ' ' << maxId << endl;
cout << minName << ' ' << minId << endl;
}
int main()
{
int n=0;
scanf("%d",&n);
fun(n);
return 0;
}