#include<iostream>
#include<string>
using namespace std;
class student{
public:
void show()
{
cout<<name<<" "<<number<<" "<<test<<endl;
}
student(string x,int y,int z);
friend void max(student *i);
private:
string name;
long int number;
int test;
};
student::student(string x,int y,int z)
{
name=x;
number=y;
test=z;
}
void max(student *i)
{
int t,e=0,big=i[0].test;
for(t=1;t<6;t++)
{
if(big<i[t].test)
{
big=i[t].test;
e=t;
}
}
cout<<"六位同学中成绩最高的是:"<<i[e].name<<endl;
cout<<"他的成绩是"<<big<<endl;
}
int main()
{
student st1[6]={
student("liming",20141143,99),
student("lihong",20141144,98),
student("lihan",20141165,57),
student("wanghan",20141161,88),
student("mingming",201411166,87),
student("jiangming",20141152,68)
};
student *p;
p=st1;
p+=1;
p->show();
p=p+2;
p->show();
p=p+2;
p->show();
max(st1);
return 0;
}
4.17&4.18
最新推荐文章于 2025-04-18 21:02:26 发布