Guest User

Untitled

a guest
Oct 15th, 2019
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Project1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8. System.SysUtils;
  9. Var
  10. x, p, firstX, arraySize, i: integer;
  11. a: array of integer;
  12. IsCorrect: boolean;
  13.  
  14. begin
  15. Writeln('This program calculates polynomial degree');
  16. IsCorrect := false;
  17. arraySize := 0;
  18. x := 0;
  19. repeat
  20. try
  21. Writeln('Please, enter integer number N( 0 < N < 1000)');
  22. Readln(arraySize);
  23. except
  24. Writeln('Warning! Enter correct number!');
  25. end;
  26. if (arraySize > 0) and (arraySize < 1000) then
  27. IsCorrect := true;
  28. until (IsCorrect);
  29. SetLength(a, arraySize);
  30. for i := 0 to arraySize - 1 do
  31. a[i] := i;
  32. IsCorrect := false;
  33. repeat
  34. try
  35. Writeln('Please, enter integer number X( 0 < X < 1000)');
  36. Readln(x);
  37. except
  38. Writeln('Warning! Enter correct number!');
  39. end;
  40. if (x > 0) and (x < 1000) then
  41. IsCorrect := true;
  42. until (IsCorrect);
  43. firstX := x;
  44. p := 0;
  45. for i := arraySize downto 1 do
  46. begin
  47. p := p + a[i] * x;
  48. a[i] := a[i] - 1;
  49. x := x * firstX;
  50. end;
  51. Writeln('Polynomial value = ', p);
  52. Readln
  53. end.
RAW Paste Data