grade.cpp

来自「Accelerated C++ 课后练习题 本人自己完成、可供参考」· C++ 代码 · 共 29 行

CPP
29
字号
#include<stdexcept>
#include<vector>
#include"grade.h"
#include"median.h"
#include"Student_info.h"
using namespace std;

//compute a student's overall grade from midterm and final exam grades
double grade(double midterm,double final,double homework)
{
	return 0.2*midterm+0.4*final+0.4*homework;
}

//compute a student's overall grade from minterm and final exam grades
//and vector of homework grades
//this funtion does not copy its argument median does so far
double grade(double midterm,double final,const vector<double>& hw)
{
	if(hw.size()==0)
		throw domain_error("student has done no homework");
	return grade(midterm,final,median(hw));
}

double grade(const Student_info& s)
{
	return grade(s.midterm,s.final,s.homework);
}
		

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?