grigory51

lab#3_3

Sep 16th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6.  double s,r,n,eps,x,h,y;
  7.  eps = 0.000001;
  8.  locale::global(locale("rus"));
  9.  s = 0; n = 1; x = 0; r = 1;
  10.  h = 0.2; // Установка шага
  11.  while (x <= 1)
  12.  {
  13.   while (abs(r) > eps)
  14.   {
  15.       r = r*((-1)/n)*x*x;
  16.       s = s + r;
  17.       n++;
  18.   }
  19.   cout << "x = " << x << "\n";         
  20.   cout << "Y(x) = " << exp(-x*x) << "\n";
  21.   cout << "S(x) = " << s << "\n";
  22.   cout << "N = "   << n <<"\n\n";
  23.   x+=h; s = 0; n = 1;
  24.   r = 1;            
  25.  }
  26.  system("pause");
  27.  return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment