AddO1f

Lab4_2

Oct 11th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "iomanip"
  4. #include "math.h"
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     bool flag = true;
  11.     double x,xn,xk,dx,y,a,n,i,y1,y2,con;
  12.     n=0; i=1;
  13.     cout << "Enter xn,xk,dx,a:" << endl;
  14.     // cin >> xn >> xk >> dx >> a;
  15.     xn = -1.5;
  16.     xk = 1.5;
  17.     dx = 0.2;
  18.     a = 2.17;
  19.     con = log10(pow(a,2));
  20.     for (x=xn; x<=xk; x=x+dx)
  21.     {
  22.         y1 = pow(x,2);
  23.         y2 = fabs(a+y1)*con+3.4;
  24.         y = pow(y2,0.5)/2;
  25.         if(flag)
  26.         {
  27.             cout << "\nx parn=" << x << endl << "y parn=" << y << endl;
  28.         }
  29.         flag = !flag;
  30.     }
  31.     for (x=xn; x<=xk; x=x+dx)
  32.     {
  33.         y1 = pow(x,2);
  34.         y2 = fabs(a+y1)*con+3.4;
  35.         y = pow(y2,0.5)/2;
  36.         if (y>0) {cout « "\ny=" « y; n=n+y; i=i*y;}
  37.     }
  38.     cout « "\nsuma=" « n «setw(10)« "proizv=" « i « endl;
  39.     system("pause");
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment