Untitled

 avatar
unknown
csharp
a year ago
1.1 kB
7
Indexable
using System;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Введите X: ");
            double X = double.Parse(Console.ReadLine());

            Console.Write("Введите Y: ");
            double Y = double.Parse(Console.ReadLine());

            Console.Write("Введите N: ");
            double N = double.Parse(Console.ReadLine());

            double result = 0;
            double factorial = 1;

            for (int i = 1; i <= N; i++)
            {
                factorial *= i;

                double term;

                if (i % 2 == 1)
                {
                    term = (Math.Pow(X, 2 * i - 2) - Math.Pow(Math.Cos(Y), i + 2)) / factorial;
                } else
                {
                    term = -(Y + Math.Pow(Math.Sin(X), i + 2)) / factorial;
                }
                    

                result += term;
            }

            Console.WriteLine($"Результат: {Math.Round(result, 2)}");
        }
    }
}
Editor is loading...
Leave a Comment