Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Posloupnost_Eurerovo_číslo
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double x, e, cosx, an;
  14. int n, P;
  15. Console.Write("Zadejte presnost na pocet desetinnych mist: ");
  16. P = int.Parse(Console.ReadLine());
  17. e = 1f;
  18. for (int i = 0; i <= P; i++)
  19. {
  20. e = e / 10;
  21. }
  22. cosx = 0;
  23. n = 0;
  24.  
  25. Console.Write("Pro vypocet sinus(x) zadej ve stupních: ");
  26. x = int.Parse(Console.ReadLine());
  27. x = ((x * Math.PI) / 180);
  28. an = 1;
  29.  
  30. while (Math.Abs(an) > e)
  31. {
  32. cosx = cosx + an;
  33. n++; // n zvýšíme o jedničku
  34. an = -an * x * x / ((2 * n) * (2 * n - 1)); //vypočteme nove an
  35. }
  36. if (cosx < 0.00000001)
  37. cosx = 0;
  38. Console.WriteLine("cos X = " + cosx);
  39. Console.ReadLine();
  40.  
  41.  
  42.  
  43.  
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement