题目点击打开链接
//============================================================================
// Name : pat.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
struct student
{
char* name;
char* className;
int mark;
};
student* newStudent()
{
student* temp=new student;
temp->name=new char[10];
temp->className=new char[10];
return temp;
}
int n;
student* big;
student* small;
student* temp;
int main() {
cin>>n;
temp=newStudent();
cin>>temp->name;
cin>>temp->className;
cin>>temp->mark;
big=small=temp;
for(int i=1;i<n;i++)
{
temp=newStudent();
cin>>temp->name;
cin>>temp->className;
cin>>temp->mark;
if(temp->mark>big->mark)
{
big=temp;
}
if(temp->mark<small->mark)
{
small=temp;
}
}
cout<<big->name<<" "<<big->className<<endl;
cout<<small->name<<" "<<small->className<<endl;
}