Advertisement
Danvil

Кек

Jan 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 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 Экзаменационная_задача
  8. {
  9.     class Program
  10.     {
  11.         static double Rd(double X,double D)
  12.         {
  13.             double res=0, dblS = 1,dblCur;
  14.             int intCounter=1,intNeg=-1;
  15.             do
  16.             {
  17.                 dblCur = intNeg * ((Math.Pow(X, (1 / dblS))) / (intCounter * (intCounter + 1)));
  18.                 res +=dblCur;
  19.                 Console.WriteLine(intNeg+"*("+X+"^(1/"+dblS+")"+":("+intCounter+"*"+(intCounter+1)+")="+res);
  20.                 dblS += 2;
  21.                 intNeg *= -1;
  22.                 intCounter++;
  23.             }
  24.             while (Math.Abs(dblCur) >= D);
  25.             return res;
  26.         }
  27.         static void Main(string[] args)
  28.         {
  29.              double dblX, dblD,dblS;
  30.              Console.Write("Введите значение X: ");
  31.              dblX = double.Parse(Console.ReadLine());
  32.              Console.Write("Введите значение D: ");
  33.              dblD = double.Parse(Console.ReadLine());
  34.              dblS = Rd(dblX, dblD);
  35.              Console.WriteLine("Полученное значение S: "+dblS);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement