
28.05.2007, 11:54
|
|
Участник форума
Регистрация: 04.11.2006
Сообщений: 150
Провел на форуме: 1174659
Репутация:
175
|
|
2. Подсчитать число максимальных элементов списка.
Код:
#include <list>
#include <algorithm>
template<typename T>
size_t CountMaxElems(const std::list<T> &ll)
{
std::list<T>::const_iterator it = std::max_element(ll.begin(), ll.end());
if(it == ll.end()) return 0;
return std::count(ll.begin(),ll.end(), *it);
}
|
|
|