Advertisement
VladimirKostovsky

А теперь нечто совершенно иное

Jun 3rd, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.01 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, math;
  9.  
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Edit1: TEdit;
  18.     Edit2: TEdit;
  19.     Label1: TLabel;
  20.     StaticText1: TStaticText;
  21.     StaticText2: TStaticText;
  22.     procedure Button1Click(Sender: TObject);
  23.     procedure FormCreate(Sender: TObject);
  24.   private
  25.  
  26.   public
  27.  
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.lfm}
  36.  
  37. { TForm1 }
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. var
  41. x, i, EPS: real;
  42. a, a1: real;
  43. begin
  44.      x:=strtofloat (Edit1.Text);
  45.      EPS:=strtofloat (Edit2.Text);
  46.      if EPS < 0 then
  47.      halt;
  48.      a := x;
  49.         a1 := 0;
  50.          i := 2;
  51.          while abs(a - a1) > EPS do begin
  52.                a1 := a;
  53.             a := 2 + (1/(EPS**i))* cos(a1 - 2*x)**2;
  54.             i += 1;
  55.          end;
  56.     Label1.Caption:=floattostr(a);
  57. end;
  58.  
  59. procedure TForm1.FormCreate(Sender: TObject);
  60. begin
  61.  
  62. end;
  63.  
  64. end.
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement