NyanCoder

Gorner.pas

May 15th, 2022
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.61 KB | None | 0 0
  1. Uses crt;
  2.  
  3. Type mas = array Of real;
  4.  
  5. Function Gorner(arr:mas; x:real; n:byte): real;
  6. Var f,s: real;
  7.   i: byte;
  8. Begin
  9.   f := 1;
  10.   s := arr[n];
  11.   For i := 1 To n Do Begin
  12.     f := f * x;
  13.     s := s + arr[n - i] * f;
  14.   End;
  15.   Gorner := s;
  16. End;
  17.  
  18. Var i,n: byte;
  19.   x: real;
  20.   arr: mas;
  21. Begin
  22.   clrscr;
  23.   write('Введите n=');
  24.   readln(n);
  25.   SetLength(arr, n + 1);
  26.   write('Введите x=');
  27.   readln(x);
  28.   writeln('Введите ', n + 1, ' коэфф. многочлена степени ', n);
  29.   For i := 0 To n Do
  30.     read(arr[i]);
  31.   write('S=', Gorner(arr, x, n):0:6);
  32.   readln;
  33. End.
  34.  
Advertisement
Add Comment
Please, Sign In to add comment