Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //нахождение среднего арифметического, геометрического, гармонического и квадратического с условием.(функция)
- #include <iostream>
- #include <cmath>
- #include <conio.h>
- using namespace std;
- float findAr(float a, float b, float c) {
- float ar = (a + b + c) / 3;
- return ar;
- }
- float findGeo(float a, float b, float c) {
- float geo = pow(a*b*c, 1. / 3);
- return geo;
- }
- float findGarm(float a, float b, float c) {
- float garm = 3 / (1 / a + 1 / b + 1 / c);
- return garm;
- }
- float findKvad(float a, float b, float c) {
- float kvad = sqrt((a*a + b * b + c * c) / 3);
- return kvad;
- }
- void condition(float a, float b, float c, float ar, float geo){
- ((a != b || b != c || a != c) && (ar > geo)) ? cout << " verno arifmeticheskoe > geometricheskogo" : cout << " neverno";
- }
- void solutions(int a){
- float x, y, z;
- for (int i = 0; i < a; ++i){
- cout <<"x=";
- cin >> x;
- cout << "y=";
- cin >> y;
- cout <<"z=";
- cin >> z;
- cout <<findAr(x, y, z) << endl;
- cout << findGeo(x, y, z) << endl;
- cout << findGarm(x, y, z) << endl;
- cout << findKvad(x, y, z) << endl;
- condition(x, y, z, findAr(x, y, z), findGeo(x, y, z));
- cout << endl;
- }
- }
- int main() {
- int k;
- cout <<"enter repetitions- ";
- cin >> k;
- solutions(k);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement