AndreyKlipikov

Prog. Lab 5. N23

Dec 18th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "cmath"
  3.  
  4. int main() {
  5.     double x = 0.1;
  6.     double h = 0.05;
  7.     int n = 15;
  8.     while (x < 1 + h)
  9.     {
  10.         double y = sin(x);
  11.         double s = 1;
  12.         for (int i = 1; i <= n; i++)
  13.         {
  14.             int k = 1;
  15.             for (int j = 2; j <= i * 2; j++)
  16.                 k *= j;
  17.             double slag = pow(x, 3) / k;
  18.             if (i % 2 == 1)
  19.                 slag *= -1;
  20.             s += slag;
  21.         }
  22.         printf("| %.4lf\t| %.4lf\t| %.4lf\t|\n", x, y, s);
  23.         x += h;
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment