第五周实验报告4
2012-03-20 14:39
190 查看
#include<iostream> using namespace std; class Student { private: int num; int score; public: void show(); int getnum(){return num;} int getscore(){return score;} Student(int a,int b):num(a),score(b){} }; void Student::show() { cout<<"学号:"<<num<<endl; cout<<"成绩:"<<score<<endl; } int showmax(Student *p); int main() { Student stu[5]= { Student(1,78), Student(2,79), Student(3,60), Student(4,87), Student(5,98) }; for(int i=0;i<=4;i=i+2) { stu[i].show(); } cout<<"成绩最大是:"<<showmax(stu)<<endl; return 0; } int showmax(Student *p) { int max; max=p[0].getscore(); for(int i=1;i<=4;i++) { if(p[i].getscore()>max) { max=p[i].getscore(); } } return max; }
相关文章推荐
- C++程序设计实验报告(三十九)---第五周任务一
- 第五周实验报告(任务1)
- 第五周实验报告(任务一)《不指定参数时的构造函数》
- 第五周实验报告(四)学生类
- 第五周实验报告(4)
- 第五周实验报告2
- 信息安全系统设计第五周实验报告
- C++程序设计实验报告(四十)---第五周任务二
- 第五周实验报告(任务一)《带参数的构造函数》
- 《第五周实验报告1-3》---增加构造函数,使对象在定义时能够进行初始化
- 第五周实验报告(任务1)
- 第五周实验报告4
- 《第五周实验报告任务3》
- 第五周实验报告3
- 第五周实验报告4
- C++程序设计实验报告(四十一)---第五周任务三
- 第五周实验报告3
- 第五周实验报告1.2
- 第五周实验报告1.4
- 《第五周实验报告2-1》---设计一个简单的分数类,完成对分数的几个运算