Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- using namespace std;
- int main()
- {
- SetConsoleOutputCP(1251);
- auto const n{ 13 };
- float D[n] = { 5, -6, 24, -9.8, 15.3, 45, -6.23, 7, 2, -7, 54.1, 12.2, -23 }, sum{}, product{ 1 }, length{}, arithmetic_mean{}, geometric_mean{};
- int i{};
- for (i = 0; i <= n - 1; i++) {
- if (D[i] > 0) {
- sum += D[i];
- product *= D[i];
- length += 1.0;
- }
- }
- arithmetic_mean = sum / length;
- geometric_mean = pow(product, 1 / length);
- cout << "Середнє арифметичне - " << arithmetic_mean << endl;
- cout << "Середнє геометричне - " << geometric_mean << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement