Ответы на вопрос:
#include < iostream> #include < array> #include < algorithm> #include < functional> template < std: : size_t size> int count(std: : array< int, size> const& arr_, std: : function< bool(int)> const& f) { return std: : count_if(arr_. arr_. f); } int main() { std: : array< int, 5> arr = { -2, 0, 5, 0, -1 }; int positive = count(arr, [](int a){ return a > 0; }); int negative = count(arr, [](int a){ return a < 0; }); int zero = count(arr, [](int a){ return a == 0; }); std: : cout < < positive < < " " < < negative < < " " < < zero; }
Популярно: Информатика
-
armodno18.05.2021 09:46
-
LOKI4613.12.2021 15:38
-
Sungatullinraf13.02.2023 14:20
-
Рабка10.02.2021 15:36
-
nikolayAK16.04.2022 11:25
-
Илья164Умникум11.05.2022 23:26
-
iroytblatилья21.05.2021 20:30
-
riaskor10.07.2022 23:46
-
daria20040721.10.2020 22:22
-
rutasolntseva01.06.2021 13:06