Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. program mdp;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5.  
  6. uses crt,FileUtil;
  7.  
  8. function f(x:real):real;
  9. begin
  10. f:=x-2+(sin(1/x));
  11. end;
  12. var a, b, c, e, x:real;
  13. begin
  14. writeln (UTF8toConsole('Введiть A'));
  15. readln (a);
  16. writeln (UTF8toConsole('Введiть B'));
  17. readln (b);
  18. writeln (UTF8toConsole('Введiть E'));
  19. readln (e);
  20. c:=(a+b)/2;
  21. while abs(a-b)>e do
  22. begin
  23. if f(a)*f(c)<0 then b:=c
  24. else a:=c;
  25. c:=(a+b)/2;
  26. end;
  27. x:=(a+b)/2;
  28. writeln ('x = ', x:3:4,' f(x)=',f(x):3:3);
  29. readkey;
  30. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement