实验报告模板1. 本学期的报告均发到csdn博客。周一上机,周四前要完成本周上机任务并发布博文。

2. 本学期起程序头部的注释请自行加入,从本学期起不再统一给出。这是一个程序员良好习惯中的一部分,养成这个习惯。这也是展示个人专业品质的一个重要途径。另外,在程序中需要的地方,也请加注释。下面是我们一直在用的注释模板。
(程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.* 文件名称:
* 作 者: 张斌
* 完成日期:2012年3月26日
* 版 本 号: 5-4-1
* 对任务及求解方法的描述部分
* 输入描述: 设计学生类,建立对象组,内放5个学生的数据
* 问题描述:
* 程序输出:
* 程序头部的注释结束
#include<iostream>
using namespace std;
class Student
{
public:
Student(int n, double s):num(n),score(s){}
void max(Student *);
void display();
private:
int num;
double score;
};
int main()
{
Student s[5] =
{
Student(1001, 55),
Student(1002, 92),
Student(1003, 48.5),
Student(1004, 57.0),
Student(1005, 78.0)
};
for(int i = 0; i < 5; i += 2)
{
Student * p = &s[i];
(*p).display();
}
s[0].max(&s[0]);
system("PAUSE");
return 0;
}
void Student::max(Student * p)
{
int n;
double max = 0;
for(int i = 0; i < 5; ++ i)
{
if(p[i].score >= max)
{
max = p[i].score;
n = i;
}
}
cout << "最高成绩为" << max << "分,学号是:" << p[n].num << endl;
}
void Student::display()
{
cout << "学号:" << num << " " << "成绩:" << score << endl;
}