hreadc2; Thr2: Threadc3 ;: real;:=(ba)/(3 * nc);:=(F (a) + F (b))/2;:=(ba)/nc;:=0 ; i:=0;:=0; k:=- 0.5;:=i+1;:=Threadc2.Create(False);.Priority:=tpHighest;.FreeOnTerminate:=True;.a:=a;.dx:=dx;.nc:=nc;.i:=i;i =Nc - 1;:=k+1;:=Threadc3.Create(False);.Priority:=tpHighest;.FreeOnTerminate:=True;.a:=a;.dx:=dx;.nc:=nc;.k:=k;k =Nc - 0.5;:=c0 * (c1 + Form1.simc2 + 2 * Form1.simc3) ;;
//формула прямоугольніковIntegralPrmg: extended; sum, dx: extended ;: real;:=(ba)/nc;:=0; k:=- 0.5;:=k + 1;:=sum + F (a + dx * k); k=(2 * nc - 1)/2;:=dx * sum ;;
//формула трапеційIntegralTrap: extended; dx, c0, c1: extended ;: integer;:=(ba)/nc;:=(F (a) + F (b))/2; :=0; i:=0;:=i + 1;:=c1 + F (a + dx * i); i=nc - 1;:=dx * (c0 + c1) ;; TForm1.Button1Click (Sender: TObject); ; simc2:=0; simc3:=0; .Caption:= raquo ;; Log thenForm1.RadioButton1.Checked then Form1.Label3.Caption:=floattostr (IntegralSimpson) Form1.RadioButton2.Checked then Form1.Label3.Caption: =floattostr (IntegralPrmg) elseForm1.RadioButton3.Checked then Form1.Label3.Caption:=floattostr(IntegralTrap);.Visible:=True;.Visible:=True;;TForm1.Button4Click(Sender: TObject) ;;;.
Вихідний текс потоку 1 (Unit2) Unit2 ;;=class (TThread)
{Private declarations} Execute; override; SIMP;, a, tr2, c, cc, c0, c1, c2, c3, nc, k: Extended;
i: integer;
end; unit1, Forms, SysUtils, UFunction;
{Threadc2} Threadc2.SIMP;:=F (a + dx * i) ;. simc2:=Form1.simc2 + c2 ;; Threadc2.Execute ;;
end;.
Вихідний текс потоку 2 (Unit3)
unit Unit3 ;;=class (TThread)
{Private declarations} Execute; override; SIMP;, a, tr2, c, cc, c0, c1, c2, c3, nc, k: Extended;
i: integer ;;
implementationunit1, Forms, SysUtils, UFunction;
{Threadc3} Threadc3.SIMP;:=F (a + dx * i) ;. simc3:=Form1.simc3 + c3 ;; Threadc3.Execute ;;
end;.
Додатковий модуль (UFunction): UFunction ;, SysUtils, Math ;: array [1..10] of string [6]=( arcsin raquo ;, arccos raquo ;, arctan , sin raquo ;, cos raquo ;, tan raquo ;, ctg raquo ;, ln raquo ;, exp raquo ;, abs );=^ extended;=^ Dat;=record, R: PExt ;: integer ;: extended ;: ElemSh ;;
Var
FStroka: string;//функція у вигляді рядка
Mch: array of PExt ;, nn: integer ;: PExt ;: extended ;: ElemSh ;: ElemSh; F (X: extended): extended;//функціяCreateSh;//створити схемуDeleteSh; //видалити схемуStrToLogstr (str: string): string; i, k: integer ;: string;:=str; pos ( raquo ;, s) lt; gt; 0 do delete (s, pos ( raquo ;, s), 1); s [1]= - then insert ( 0 raquo ;, s, 1) ;; pos ( (- raquo ;, s) lt; gt; 0 do insert ( 0 raquo ;, s, pos ( (- raquo ;, s ) +1); i:=low (a) to high (a) dopos (a [i], s) lt; gt; 0 do ( f + inttostr (i), s, pos (a [i ], s)); (s, pos (a [i], s), length (a [i])) ;;:=0;:=i + 1; s [i]= f then: =i + 1; s [k] lt; gt; ( do:=k + 1; k gt; length (s) then break ;;:=i + (ki - 1); elses [i] in [ 0 .. 9 raquo ;, , raquo ;, . ] then:=i; s [k] in [ 0 .. 9 raquo ;, , raquo ;, . ] do:=k + 1; k gt; length (s) then break ;;:=n + 1;:=new (PExt); (MCh, n + 1); [n] :=p; ^:=strtofloat (copy (s, i, ki)); (s, i, ki); ( lt; + inttostr (n) + gt; raquo ;, s, i ); n lt; 10 then i:=i + 2 else if n lt; 100 then i:=i + 3 else if n lt; 1000 then i:=i + 4; else (s [i]= p raquo ;) or (s [i]= e ) then:=new (PExt); s [i]= p then p ^:=pi else p ^:=exp (1); s [i ]= p then delete (s, i, 2) else delete (s, i, 1);:=n + 1; ( lt; + inttostr (n) + gt; , s, i); (MCh, n + 1); [n]:=p; n lt; 10 then i:=i + 2 else if n lt; 100 then i:=i + 3 else if n lt; 1000 then i:=i + 4; elses [i]= x then (s, i, 1);:=n + 1; ( lt; + inttostr (n) + gt; raquo ;, s, i); (MCh, n + 1); [n ]:=@ FX; n lt; 10 then i:=i + 2 else if n lt; 100 then i:=i + 3 else if n lt; 1000 then i:=i + 4 ;; i gt;=length (s);:=n;:=s ;; InsUz (AddrL, AddrR: PExt; fnd: integer; var U: ElemSh); (U); ^ .L:=AddrL; ^. R:=AddrR; ^. fn:=fnd; ^. Next:=nil ;; Fbs (str: string): string; i, k, t, m, NOper: integer;:string ;: ElemSh;:=str; (pos ( ^ raquo ;, s) lt; gt; 0) or (pos ( * raquo ;, s) lt; gt; 0) or (pos ( laquo ;/ raquo ;, s) lt; gt; 0) do:=U;:=4; not (s [i] in [ ^ raquo ;, * raquo ;, /]) do i:=i + 1;:=0; s [i]= * then NOper:=high (a) +3 elses [i]=/ then NOper:=high (a) +4 elses [i]= ^ then NOper:=high (a) +5;:=i - 2; s [k - 1] lt; gt; lt; do k:=k - 1;//(k - 1) - поз. lt; :=strtoint (copy (s, k, ik - 1));:=k;:=i + 2; s [k + 1] lt; gt; gt; do k:=k + 1;//(k + 1) - поз. gt; (Mch [m], Mch [strtoint (copy (s, i + 2, ki - 1))], NOper, U); Q lt; gt; nil th...