C# Запишите алгоритм для решения задачи циклической структуры

Приложения:

Ответы

Ответ дал: orakul96
0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace AutoIT

{

   internal class Program

   {

       

       

       static void Main(string[] args)

       {

           Console.OutputEncoding = Encoding.UTF8;

           double x, n;

           Console.WriteLine("Введите Х");

           x = int.Parse(Console.ReadLine());

           Console.WriteLine("Введите, с какой точностью будут выполнены расчёты");

           n = int.Parse(Console.ReadLine());

          Console.WriteLine(Function(x, n));

           Console.ReadLine();

           

       }

       static double Function(double value, double count)

       {

           double result  = 0;

           for (int i = 0; i <=count; i++)

           {

               result += (Math.Pow(-1, i) * Math.Pow(value, (2 * i))) / Factorial(i);

           }

           return result;

       }

       static double Factorial(double n)

       {

           if (n == 0) return 1;

           else return n * Factorial(n - 1);

       }

   }

}

Вас заинтересует