#include<iostream>
#include<string>
using namespace std;
class student{
public:
student(string num1,float score1){
num=num1;score=score1;}
void max(student *op){
int i,j;
float big;
big=op->score;
for(i=0;i<6;i++)
if(op[i].score>big)
{ big=op[i].score;j=i;}
cout<<"6个学生中成绩最高的同学的学号和成绩是: "<<op[j].num<<":"<<big<<endl;}
private:
string num;
float score;
};
int main(){
student stu[6]={
student("01",88),
student("02",89),
student("03",93),
student("04",94),
student("05",95),
student("06",97)};
stu[0].max(stu);
return 0;
}
4.18
最新推荐文章于 2024-04-19 12:21:04 发布