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 Lagranzh
- {
- class Program
- {
- static double funct(double xi)
- {
- return xi * xi * xi / 4;
- }
- static void Main(string[] args)
- {
- double y;
- double sum = 0;
- double pr = 1;
- Console.WriteLine("Please, enter number of intermediate values");
- int n = int.Parse(Console.ReadLine());
- List<double> ixi = new List<double>();
- for(int i=0;i<n;i++)
- {
- Console.WriteLine("Enter {0} intermediate value", i);
- double iks = Convert.ToDouble(Console.ReadLine());
- ixi.Add(iks);
- }
- Console.WriteLine("Please enter the x = ");
- double x = double.Parse(Console.ReadLine());
- for (int i=0;i<ixi.Count;i++)
- {
- y = funct(ixi[i]);
- for (int j=0;j<n;j++)
- {
- if (i != j)
- {
- pr *= (x - ixi[j]) / (ixi[i] - ixi[j]);
- }
- }
- sum += y * pr;
- pr = 1;
- }
- Console.WriteLine();
- Console.WriteLine("{0}", sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement