Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Posloupnost_Eurerovo_číslo
- {
- class Program
- {
- static void Main(string[] args)
- {
- double x, e, cosx, an;
- int n, P;
- Console.Write("Zadejte presnost na pocet desetinnych mist: ");
- P = int.Parse(Console.ReadLine());
- e = 1f;
- for (int i = 0; i <= P; i++)
- {
- e = e / 10;
- }
- cosx = 0;
- n = 0;
- Console.Write("Pro vypocet sinus(x) zadej ve stupních: ");
- x = int.Parse(Console.ReadLine());
- x = ((x * Math.PI) / 180);
- an = 1;
- while (Math.Abs(an) > e)
- {
- cosx = cosx + an;
- n++; // n zvýšíme o jedničku
- an = -an * x * x / ((2 * n) * (2 * n - 1)); //vypočteme nove an
- }
- if (cosx < 0.00000001)
- cosx = 0;
- Console.WriteLine("cos X = " + cosx);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement