学过java基础,这道题真的一上来就想来个class然后一顿操作,应该也是可以,但是单纯用for循环ac不是也香香
上代码
int num;
int score;
string name;
string name1;
string name2;
string course;
string course1;
string course2;
int a = 0;
int b = 100;
cin >> num;
for (size_t i = 0; i < num; i++)
{
cin >> name >> course >> score;
if (score < b)
{
b = score;
name1 = name;
course1 = course;
}
if (score > a)
{
a = score;
name2 = name;
course2 = course;
}
}
cout << name2 << " " << course2 << endl;
cout << name1 <<" "<< course1 << endl;