Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Horner
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double ilosc;
  10. Console.WriteLine("Podaj ktorego stopnia bedzie wielomian:");
  11. string liczba = Console.ReadLine();
  12.  
  13. int rozmiar = int.Parse(liczba);
  14. double[] tablica = new double[rozmiar + 1];
  15. int j = rozmiar;
  16. for (int i = 0; i <= rozmiar; i++)
  17. {
  18. Console.WriteLine("Podaj stopień {0}:", j);
  19. j--;
  20. string wsp = Console.ReadLine();
  21. double wspolczynnik = double.Parse(wsp);
  22. tablica[i] = wspolczynnik;
  23.  
  24. }
  25. double wynik = 0;
  26. Console.WriteLine("Podaj x:");
  27. string a = Console.ReadLine();
  28. double x = double.Parse(a);
  29. for (int k = 0; k <= rozmiar; k++)
  30. {
  31. wynik = wynik * x + tablica[k];
  32. }
  33. Console.WriteLine("Wynik: {0}", wynik);
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement