#ifndef MEAN_MARK_H #define MEAN_MARK_H #include #include #undef SOLVED_3 #define SOLVED_3 namespace Ti { template double mean_mark(Iter first, Iter last) { double result = 0; unsigned count = 0; for(; first != last; ++first) { result += (*first)->mark(); ++count; } return (count == 0) ? 0 : result / count; } template double mean_mark_student(Iter first, Iter last) { double result = 0; unsigned count = 0; for(; first != last; ++first) { /*if (typeid(*(*first)) != typeid(Student)) continue;*/ Student *s = dynamic_cast(&(*(*first))); if (s == NULL) continue; result += s->mark(); ++count; } return (count == 0) ? 0 : result / count; } template ForwardIterator remove_greater (ForwardIterator first, ForwardIterator last, int mark) { ForwardIterator result = first; for (; first != last; ++first) { if ((*first)->mark() <= mark) { *result = *first; ++result; } } return result; } } #endif /* vim: set et sw=2 ts=2: */