Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it.
- //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- // Wielomian Lagrange'a
- int n;
- double [n+1] wspx; // współczynnik x
- double [n+1] wspy; // współczynnik y
- double wartosc;
- double x; // x dla którego będziemy wyliczać wartość
- double licznik, mianownik;
- wartosc = 0;
- for (int i=0; i<=n; i++)
- {
- licznik = 1;
- mianownik = 1;
- for (int j=0; j<=n; j++)
- {
- if(j!=i)
- {
- licznik = licznik * (x-wspx[j])
- mianownik = mianownik * (wspx[i]-wspx[j]);
- }
- }
- wartosc = wspy[i]*licznik/mianownik;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement