Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Rextester
  10. {
  11. public class Program
  12. {
  13. public static void Main(string[] args)
  14. {
  15. // Wielomian Lagrange'a
  16.  
  17. int n;
  18. double [n+1] wspx; // współczynnik x
  19. double [n+1] wspy; // współczynnik y
  20. double wartosc;
  21. double x; // x dla którego będziemy wyliczać wartość
  22. double licznik, mianownik;
  23.  
  24. wartosc = 0;
  25.  
  26.  
  27. for (int i=0; i<=n; i++)
  28. {
  29. licznik = 1;
  30. mianownik = 1;
  31.  
  32. for (int j=0; j<=n; j++)
  33. {
  34. if(j!=i)
  35. {
  36. licznik = licznik * (x-wspx[j])
  37. mianownik = mianownik * (wspx[i]-wspx[j]);
  38. }
  39. }
  40.  
  41. wartosc = wspy[i]*licznik/mianownik;
  42.  
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement