没注释的源代码
#include <iostream>
using namespace std;
class student
{
public:
int num;
float score;
student(int n,float s):num(n),score(s){}
};
void max(student *arr);
int main()
{
student s[5]={
student(1001,98),
student(1002,97),
student(1003,96),
student(1004,95),
student(1005,93)};
student *p=&s[0];
max(p);
return 0;
}
void max(student *arr)
{
float max_score=arr[0].score;
int max_i=0;
for (int i=1;i<=5;i++)
{
if(arr[i].score>max_score)
{
max_score=arr[i].score;
max_i=i;
}
}
cout<<arr[max_i].num<<" "<<arr[max_i].score;
}