C/C++

Помогите решить С++ пожалуйста

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <array>
#include <random>
#include <numeric>
#include <iterator>
using namespace std;
template<typename Type, streamsize Width>
class Output {
public:
Output(Type value) : value(value) {}
private:
Type value;
friend ostream& operator<<(ostream& out, const Output<Type, Width>& w) {
return out << setw(Width) << w.value;
}
};
int main() {
uniform_int_distribution<> uid(-9999, 9999);
mt19937 gen{ random_device()() };
array<double, 16> box{};
generate(box.begin(), box.end(), [&] { return uid(gen) / 100.0; });
const streamsize width = 6;
cout << fixed << setprecision(2);
copy(box.begin(), box.end(), ostream_iterator<Output<double, width>>(cout, "\n"));
auto count_neg = count_if(box.begin(), box.end(), [](double x) {
return x < 0;
});
auto sum_neg = accumulate(box.begin(), box.end(), 0.0, [](double s, double x) {
return x < 0? s + x : s;
});
auto avg_neg = sum_neg / count_neg;
cout << "\n Average negative: " << avg_neg << '\n';
auto count_pos = count_if(box.begin(), box.end(), [](double x) {
return x > 0;
});
auto sum_pos = accumulate(box.begin(), box.end(), 0.0, [](double s, double x) {
return x > 0? s + x : s;
});
auto avg_pos = sum_pos / count_pos;
cout << " Average positive: " << avg_pos << "\n\n";
transform(box.begin(), box.end(), box.begin(), [avg_neg](double x) {
return x < avg_neg? avg_neg : x;
});
transform(box.begin(), box.end(), box.begin(), [avg_pos](double x) {
return x > avg_pos? avg_pos : x;
});
copy(box.begin(), box.end(), ostream_iterator<Output<double, width>>(cout, "\n"));
system("pause > nul");
}
Избас Избас
Избас Избас
73 839
Лучший ответ