#include<iostream>
#include<string>
using namespace std;
class student
{
public:
student(int c,string a,double b)
{
num=c;
name=a;
score=b;
}
friend void max(student *p,int c);
private:
int num;
string name;
double score;
};
void max(student *p,int c)
{
int big;
int d;
big=p[0].score;
for(int i=0;i<c;i++)
if(big<=p[i].score)
{big=p[i].score;d=i;}
cout<<"6个同学中成绩最高的是:"<<p[d].num<<" "<<p[d].name<<" "<<big<<endl;
}
int main()
{
student stu[6]={student(1,"wubeiren",88),student(2,"yanwenfa",99),student(3,"lianjingxin",95),student(4,"lvyingchuang",97),
student(5,"zhangya",89),student(6,"liyifan",100)};
max(stu,6);
return 0;
}
08-20
08-20
08-20
08-20
08-20
08-20