
Mitik
4 год назад
Составьте алгоритм вычисления суммы целых чисел x, y, z. Определитьчетная ли она, если четная, то найти среднее арифметическое значениеданных чисел, если нечетная, то найти их среднее геометрическое значение.
ОТВЕТЫ

Лев
Oct 24, 2020
// Example program C++
#include <iostream>
#include <cmath>
int main(){int x,y,z,sum;
double itog;
std::cout << "x" << "y" << "zn";
std::cin >> x >> y >> z;sum = x+y+z;
std::cout << "ostatok: " << sum%2;
if (sum%2 > 0) {
itog = std::sqrt (x*y*z);
std::cout << "nSrednee geom is: " << itog;}
else {
itog = sum/3;std::cout << "nSrednee arif is: " << itog;
}
return 0;
}
#include <iostream>
#include <cmath>
int main(){int x,y,z,sum;
double itog;
std::cout << "x" << "y" << "zn";
std::cin >> x >> y >> z;sum = x+y+z;
std::cout << "ostatok: " << sum%2;
if (sum%2 > 0) {
itog = std::sqrt (x*y*z);
std::cout << "nSrednee geom is: " << itog;}
else {
itog = sum/3;std::cout << "nSrednee arif is: " << itog;
}
return 0;
}
166