Advertisement
MyOnAsSalat

Untitled

Nov 19th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. class Program
  2. {
  3.     static void Main()
  4.     {
  5.         Console.WriteLine("Введите X: ");
  6.         double x = double.Parse(Console.ReadLine());
  7.         Console.WriteLine("Введите K: ");
  8.         double k = int.Parse(Console.ReadLine());
  9.         Console.WriteLine("Введите EPS: ");
  10.         double EPS = double.Parse(Console.ReadLine());
  11.         if (Math.Abs(x) > 1)
  12.         {
  13.             Console.WriteLine("Неверное значение аргумента");
  14.             Console.ReadKey();
  15.             return;
  16.         }
  17.         double sum = 0.5 * Math.PI - x;
  18.         double tmp = x, eps;
  19.         eps = EPS;        
  20.         for (int i = 1; ; i++)
  21.         {
  22.             tmp *= (x * x * (2 * i - 1)) / (2 * i);
  23.            
  24.             if (sum < eps) break;
  25.         }
  26.         Console.WriteLine("f1()");
  27.         Console.WriteLine(sum);
  28.         sum = 0.5 * Math.PI - x;
  29.         double tmp2 = x, eps2;
  30.         Console.WriteLine("f2()");
  31.         for (int i = 1; i < k; i++)
  32.         {
  33.             tmp2 *= (x * x * (2 * i - 1)) / (2 * i);
  34.             eps2 = tmp2 / (2 * i + 1);
  35.             sum -= eps2;
  36.         }
  37.         Console.WriteLine(sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement