#include<iostream>
#include<cstdlib>
using namespace std;
class student{
private:
public:
int number,math;
void stu(int num,int m)
{
number=num;
math=m;
}
};
void max(student *p)
{
int i,j;
student s[1];
s[0].math=(*p).math;
s[0].number=(*p).number;
p++;
for(j=0;j<6-1;j++)
{
if((*p).math>s[0].math)//数组元素大小按升序排列
{
s[0].math=(*p).math;
s[0].number=(*p).number;
p++;
}
}
cout<<s[0].number<<" "<<s[0].math<<endl;
}
int main()
{
student stu[6];
stu[0].stu(01,88);
stu[1].stu(02,90);
stu[2].stu(03,100);
stu[3].stu(04,94);
stu[4].stu(05,96);
stu[5].stu(06,98);
student *q;
q=stu;
max(q);
system("pause");
return 0;
}
4.18
最新推荐文章于 2024-04-19 12:21:04 发布