Вмассиве в(11) все элементы из интервала (a,b) занесите в массив с и найдите сумму элементов полученного массива в с++. 30 .

Dodgesantafe Dodgesantafe    3   30.09.2019 23:40    1

Ответы
Голубь20079 Голубь20079  27.08.2020 10:28

Т.к. a и b были не заданы, взял с 0 по size.

#include <iostream> #include <array> #include <algorithm> #include <numeric> constexpr std::size_t SIZE = 11u; int main() {    std::array<int, SIZE> b{ -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 };    std::array<int, SIZE> c;    std::transform(b.begin(), b.end(), c.begin(), [](int const& x) { return x; });    std::cout << std::accumulate(c.begin(), c.end(), 0); }
ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика