Advertisement
MyOnAsSalat

Untitled

Nov 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. Console.WriteLine("Введите X: ");
  8. double x = Convert.ToDouble(Console.ReadLine());
  9. Console.WriteLine("Введите K: ");
  10. double k = Convert.ToDouble(Console.ReadLine());
  11. Console.WriteLine("Введите EPS: ");
  12. double EPS = Convert.ToDouble(Console.ReadLine());
  13. if (Math.Abs(x) > 1)
  14. {
  15. Console.WriteLine("Неверное значение аргумента");
  16. return;
  17. }
  18. double s = 0;
  19. double last = 0;
  20. for (int i = 0; ; i++)
  21. {
  22. double cur = (f(2 * i) * Math.Pow(x, 2 * i + 1)) / ((Math.Pow(4, i) * Math.Pow(f(i), 2) * (2 * i + 1)));
  23. if (Math.Abs(cur - last) < EPS) break;
  24. s += cur;
  25. last = cur;
  26. }
  27. Console.WriteLine("f1()");
  28. Console.WriteLine(Math.PI / 2 - s);
  29. s = 0;
  30. last = 0;
  31. for (int i = 0;i<=k ; i++)
  32. {
  33. double cur = (f(2 * i) * Math.Pow(x, 2 * i + 1)) / ((Math.Pow(4, i) * Math.Pow(f(i), 2) * (2 * i + 1)));
  34.  
  35. s += cur;
  36. last = cur;
  37. }
  38. Console.WriteLine("f2()");
  39. Console.WriteLine(Math.PI/2 - s);
  40. Console.WriteLine("f()");
  41. Console.WriteLine(Math.Acos(x));
  42. Console.ReadKey();
  43.  
  44. }
  45. //факториал
  46. static double f(int x)
  47. {
  48. return (x == 0) ? 1 : x * f(x - 1);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement