Quipex icon

zadanie_4_XIII

Quipex | PRO | 10/11/15 08:19:56 PM UTC | 0 ⭐ | 260 👁️ | Never ⏰ | []
C++ |

920 B

|

None

|

0 👍

/

0 👎

// Zadanie_4_XIII.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <clocale>
#include <iomanip>
#include <math.h>
using namespace std;
 
 
int main()
{
    setlocale(LC_CTYPE, "rus"); //кириллица в консоли
    double xn,xk,dx,a,b,y,x,sarifm=0,sgeom=1;
    int c=0,sa=0,sg=0;
    cout<<"Введите xn, xk, dx, a, b:"<<endl;
    cin>>xn>>xk>>dx>>a>>b;
    //xn=-3; xk=3; dx=0.1; a=6.42; b=3.17;
    for(x=xn;x<=xk;x+=dx)
    {
        y=powf(a*pow(b*abs(x),1.0 / 3)+abs(x),1.0 / 5)/12;
        if(x<0)
            y*=-1;
        c++;
        if(c%3==0)
        {
            cout<<setw(15)<<x<<setw(15)<<y<<endl;
        }
        if(y>0)
        {
            sarifm+=y;
            sa++;
        }
        if(y<0)
        {
            sgeom*=y;
            sg++;
        }
    }
    cout<<"Среднее арифм среди полож: "<<sarifm/sa<<endl;
    if(sg>=1)
        cout<<"Среднее геом среди отриц: "<<powf(abs(sgeom),1*1.0/sg)<<endl;
    return 0;
}

Comments