/*
* Copyright (c) 2011, 烟台大学计算机学院
* All rights reserved.
* 作 者:王静
* 完成日期:2013 年 4 月 2 日
* 版 本 号:v1.0
* 输入描述:
* 问题描述:
* 程序输出:
* 问题分析:
* 算法设计:略
*/
#include <iostream>
using namespace std;
class Student
{private:
int num;
double score;
public:
Student(int n,double s):num(n),score(s){}
void output();
int getNum(){return num;}
double getScore(){return score;}
};
int max(Student *arr)
{
double max=(arr[0].getScore());
int n=(arr[0].getNum());
for(int i=1;i<5;i++){
if((arr[i].getScore())>max){
n=(arr[i].getNum());
}
}
return n;
}
void Student::output ()
{
cout<<"学生的学号,成绩是"<<endl;
cout<<num<<" "<<score<<endl;
}
int main()
{
Student s[5]={Student(10001,98),Student(20001,94),
Student(10021,97),Student(10322,98),Student(20002,99)};
s[0].output();
s[2].output();
s[4].output();
cout<<max(s)<<endl;
return 0;
}
运行结果:
(贴图)
心得体会: