5_24.cpp
来自「c++书籍的源代码」· C++ 代码 · 共 23 行
CPP
23 行
//5_24.cpp
#include<iostream.h>
#include"student.h"
student* get_max(student *p);
int main()
{
int i;
student a[3]={student("王杰",70),student("成龙",75),student("周星驰")},*p;
for(i=0;i<3;i++)
a[i].display();
p=get_max(a);
cout<<"考得最好的同学是:"<<endl;
p->display();
return(0);
}
student* get_max(student *p)
{
student *q=p;
for(int i=0;i<3;i++,p++)
if(q->get_s()<p->get_s())
q=p;
return(q);//返回拥有最高分的学生元素的指针
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?