/* * exercise_1.cpp * * Created on: 29 сент. 2021 г. * Author: alexander */ #include #include "exercise_1.hpp" using namespace std; void printList(list &l) { cout << "{ "; for (list::const_iterator iter = l.begin(); iter != l.end(); ++iter) { cout << *iter << (next(iter, 1) == l.end() ? " " : ", "); } cout << '}' << endl; } void pushBackList(list &l) { float sum = 0; for (const float &value : l) { sum += value; } l.push_back(sum / l.size()); } void exercise_1() { list l { 54.46, 43.32, 37.89, 19.99 }; size_t countCycle = 15; for (size_t i = 0; i < countCycle; ++i) { // Печать листа через каждых 5-и добавлений элементов if (i % 5 == 0) { printList(l); } pushBackList(l); } printList(l); }