Quipex

zadanie_4_XIII

Oct 11th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. // Zadanie_4_XIII.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <clocale>
  7. #include <iomanip>
  8. #include <math.h>
  9. using namespace std;
  10.  
  11.  
  12. int main()
  13. {
  14.     setlocale(LC_CTYPE, "rus"); //кириллица в консоли
  15.     double xn,xk,dx,a,b,y,x,sarifm=0,sgeom=1;
  16.     int c=0,sa=0,sg=0;
  17.     cout<<"Введите xn, xk, dx, a, b:"<<endl;
  18.     cin>>xn>>xk>>dx>>a>>b;
  19.     //xn=-3; xk=3; dx=0.1; a=6.42; b=3.17;
  20.     for(x=xn;x<=xk;x+=dx)
  21.     {
  22.         y=powf(a*pow(b*abs(x),1.0 / 3)+abs(x),1.0 / 5)/12;
  23.         if(x<0)
  24.             y*=-1;
  25.         c++;
  26.         if(c%3==0)
  27.         {
  28.             cout<<setw(15)<<x<<setw(15)<<y<<endl;
  29.         }
  30.         if(y>0)
  31.         {
  32.             sarifm+=y;
  33.             sa++;
  34.         }
  35.         if(y<0)
  36.         {
  37.             sgeom*=y;
  38.             sg++;
  39.         }
  40.     }
  41.     cout<<"Среднее арифм среди полож: "<<sarifm/sa<<endl;
  42.     if(sg>=1)
  43.         cout<<"Среднее геом среди отриц: "<<powf(abs(sgeom),1*1.0/sg)<<endl;
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment