ΠΠ½Π΄ΠΈΠ²ΠΈΠ΄ΡΠ°Π»ΡΠ½ΠΎΠ΅ Π·Π°Π΄Π°Π½ΠΈΠ΅.
ΠΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ ΡΠ΅ΡΠ΅Π½ΠΈΡ ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΡ
Π·Π°Π΄Π°Ρ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ ΡΠ·ΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Pascal
ΠΠ»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠ°Π±ΠΎΡΠΎΠΉ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΠΠΠΠΠΠ (Button ΠΈΠ»ΠΈ BitBtn). Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, XPMan, Grids, ExtCtrls, Vcl.Imaging.jpeg; Π ΠΈΡΡΠ½ΠΎΠΊ 3.1 — ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ (ΠΡΠ²ΠΎΠ΄ Π·Π½Π°ΡΠ΅Π½ΠΈΡ Π² StringGrid). Memo1.Lines.Add ('ΠΠΎΠΌΠ΅Ρ ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ X Π€ΡΠ½ΠΊΡΠΈΡ Y1 Π€ΡΠ½ΠΊΡΠΈΡ Y2 Π€ΡΠ½ΠΊΡΠΈΡ Y3'); Π ΠΈΡΡΠ½ΠΎΠΊ 3.2 — ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅… Π§ΠΈΡΠ°ΡΡ Π΅ΡΡ >
ΠΠ½Π΄ΠΈΠ²ΠΈΠ΄ΡΠ°Π»ΡΠ½ΠΎΠ΅ Π·Π°Π΄Π°Π½ΠΈΠ΅. ΠΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ ΡΠ΅ΡΠ΅Π½ΠΈΡ ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΡ Π·Π°Π΄Π°Ρ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ ΡΠ·ΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Pascal (ΡΠ΅ΡΠ΅ΡΠ°Ρ, ΠΊΡΡΡΠΎΠ²Π°Ρ, Π΄ΠΈΠΏΠ»ΠΎΠΌ, ΠΊΠΎΠ½ΡΡΠΎΠ»ΡΠ½Π°Ρ)
Π Π°Π·ΡΠ°Π±ΠΎΡΠ°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡ ΡΠ°Π±Π»ΠΈΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ ΡΡΠ½ΠΊΡΠΈΠΉ ΠΎΠ΄Π½ΠΎΠΉ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ. ΠΡΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ ΡΡΠ½ΠΊΡΠΈΠΈ ΠΎΡΠΎΡΠΌΠΈΡΡ Π² Π²ΠΈΠ΄Π΅ ΠΎΡΠ΄Π΅Π»ΡΠ½ΠΎΠΉ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΎΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ.
ΠΡΠ΅Π΄ΡΡΠΌΠΎΡΡΠ΅ΡΡ ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΡΡ ΠΎΡΠΈΠ±ΠΎΠΊ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. ΠΡΠΈ Π΄Π΅Π»Π΅Π½ΠΈΠΈ Π½Π° Π½ΠΎΠ»Ρ, Π² ΡΡΠ΅ΠΉΠΊΡ StringGrid ΠΈΠ»ΠΈ Π² ΡΡΡΠΎΠΊΡ Memo Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π²ΡΠ²ΠΎΠ΄ΠΈΡΡΡΡ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠ΅Π΅ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅. ΠΡΠ²ΠΎΠ΄ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ² ΠΎΡΠ³Π°Π½ΠΈΠ·ΠΎΠ²Π°ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ StringGrid, Memo.
ΠΠ»Ρ ΠΎΡΠ³Π°Π½ΠΈΠ·Π°ΡΠΈΠΈ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΠΉ ΡΠ°Π±ΠΎΡΡ ΡΠ΅Π°Π»ΠΈΠ·ΠΎΠ²Π°ΡΡ ΡΡΠ΅Π½Π°ΡΠΈΠΉ ΡΠ°Π±ΠΎΡΡ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΡΠ²ΠΎΠΉΡΡΠ² visible ΠΈ (ΠΈΠ»ΠΈ) enabled ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ, ΡΠ°Π·ΠΌΠ΅ΡΠ΅Π½Π½ΡΡ Π½Π° ΡΠΎΡΠΌΠ΅.
ΠΠ»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠ°Π±ΠΎΡΠΎΠΉ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΠΠΠΠΠΠ (Button ΠΈΠ»ΠΈ BitBtn).
Π€ΡΠ½ΠΊΡΠΈΡ:
Π’Π΅ΠΊΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
unit Unit1;
interface.
uses.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, XPMan, Grids, ExtCtrls, Vcl.Imaging.jpeg;
type.
TForm1 = class (TForm).
GroupBox1: TGroupBox;
Edit1: TEdit;
XPManifest1: TXPManifest;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Edit3: TEdit;
GroupBox2: TGroupBox;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
GroupBox3: TGroupBox;
StringGrid1: TStringGrid;
SpeedButton3: TSpeedButton;
Image1: TImage;
ComboBox1: TComboBox;
Memo1: TMemo;
Label1: TLabel;
procedure SpeedButton2Click (Sender: TObject);
procedure SpeedButton1Click (Sender: TObject);
procedure SpeedButton3Click (Sender: TObject);
private.
{ Private declarations }.
public.
{ Public declarations }.
end;
var.
Form1: TForm1;
implementation.
{$R *.dfm}.
function f1(x:real):real;
begin.
f1:=(14*x+5)/(x*x+1);
end;
function f2(x:real):real;
begin.
f2:=12+x;
end;
function f3(x:real):real;
begin.
f3:=(x*x*x+1)/(4*x+2);
end;
procedure TForm1. SpeedButton2Click (Sender: TObject);
begin.
Close;
end;
procedure TForm1. SpeedButton1Click (Sender: TObject);
var.
code_a, code_b, code_n:integer;
a, b, h:real;
n, i: integer;
x, y1, y2,y3:real;
begin.
Val (Edit1.Text, a, code_a);
Val (Edit2.Text, b, code_b);
Val (Edit3.Text, n, code_n);
If (code_a0) then.
begin.
Showmessage ('ΠΠ΅ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π²Π²Π΅Π΄Π΅Π½ A');
Edit1.SetFocus;
end.
else.
If (code_b0) then.
begin.
Showmessage ('ΠΠ΅ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π²Π²Π΅Π΄Π΅Π½ B');
Edit2.SetFocus;
end.
else.
If (code_n0) then.
begin.
Showmessage ('ΠΠ΅ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π²Π²Π΅Π΄Π΅Π½ N');
Edit3.SetFocus;
end;
if (code_a=0)and (code_b=0)and (code_n=0) then.
begin.
GroupBox3.Visible:=true;
if ComboBox1. Text='Memo' then.
begin.
StringGrid1.Visible:=false;
Memo1.Visible:=true;
end.
else if ComboBox1. Text='StringGrid' then.
begin.
StringGrid1.Visible:=true;
Memo1.Visible:=false;
end.
else.
begin.
ShowMessage ('ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΎΠ΄ΠΈΠ½ ΠΈΠ· ΠΏΡΠ½ΠΊΡΠΎΠ²!!!');
exit;
end;
StringGrid1.Cells[0,0]: ='β';
StringGrid1.Cells[1,0]: =' X=';
StringGrid1.Cells[2,0]: =' Y1=';
StringGrid1.Cells[3,0]: =' Y2=';
StringGrid1.Cells[4,0]: =' Y3=';
StringGrid1.RowCount:=n+1;
for i:=1 to n do.
StringGrid1.Cells[0,i]: =IntToStr (i);
x:=a;
i:=1;
h:=(b-a)/n;
Memo1.Clear;
Memo1.Lines.Add ('ΠΠΎΠΌΠ΅Ρ ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ X Π€ΡΠ½ΠΊΡΠΈΡ Y1 Π€ΡΠ½ΠΊΡΠΈΡ Y2 Π€ΡΠ½ΠΊΡΠΈΡ Y3');
while x<=b do.
begin.
StringGrid1.Cells[1,i]: =FloatToStrF (x, ffFixed, 5,1);
// Π€ΡΠ½ΠΊΡΠΈΠΈ.
if x=-2 then.
begin.
y1:=f1(x);
y2:=f2(x);
StringGrid1.Cells[4,i]: ='ΠΠ΅Π»Π΅Π½ΠΈΠ΅ Π½Π° 0';
StringGrid1.Cells[3,i]: =FloatToStrF (y2,ffFixed, 5,5);
StringGrid1.Cells[2,i]: =FloatToStrF (y1,ffFixed, 5,5);
Memo1.Lines.Add (IntToStr (i)+' '+FloatToStrF (x, ffExponent, 5,2)+ ' '+.
FloatToStrF (y1,ffExponent, 5,2)+.
' '+FloatToStrF (y2,ffExponent, 5,2)+.
' ΠΠ΅Π»Π΅Π½ΠΈΠ΅ Π½Π° Π½ΠΎΠ»Ρ ');
end.
else.
if x=0 then.
begin.
StringGrid1.Cells[2,i]: ='ΠΠ΅Π»Π΅Π½ΠΈΠ΅ Π½Π° 0';
y2:=f2(x);
y3:=f3(x);
StringGrid1.Cells[3,i]: =FloatToStrF (y2,ffFixed, 5,5);
StringGrid1.Cells[4,i]: =FloatToStrF (y3,ffFixed, 5,5);
Memo1.Lines.Add (IntToStr (i)+' '+FloatToStrF (x, ffExponent, 5,2)+.
' ΠΠ΅Π»Π΅Π½ΠΈΠ΅ Π½Π° Π½ΠΎΠ»Ρ '+.
' '+FloatToStrF (y2,ffExponent, 5,2)+' '+.
FloatToStrF (y3,ffExponent, 5,2));
end.
else.
begin.
y1:=f1(x);
y2:=f2(x);
y3:=f3(x);
StringGrid1.Cells[2,i]: =FloatToStrF (y1,ffFixed, 5,5);
StringGrid1.Cells[3,i]: =FloatToStrF (y2,ffFixed, 5,5);
StringGrid1.Cells[4,i]: =FloatToStrF (y3,ffFixed, 5,5);
Memo1.Lines.Add (IntToStr (i)+' '+FloatToStrF (x, ffExponent, 4,2)+.
' '+FloatToStrF (y1,ffExponent, 4,2)+.
' '+FloatToStrF (y2,ffExponent, 4,2)+.
' '+FloatToStrF (y3,ffExponent, 4,2));
end;
x:=x+h;
inc (i);
end;
end;
end;
procedure TForm1. SpeedButton3Click (Sender: TObject);
begin.
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
GroupBox3.Visible:=false;
end;
end.
Π ΠΈΡΡΠ½ΠΎΠΊ 3.1 — ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ (ΠΡΠ²ΠΎΠ΄ Π·Π½Π°ΡΠ΅Π½ΠΈΡ Π² StringGrid).
Π ΠΈΡΡΠ½ΠΎΠΊ 3.2 — ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ (ΠΡΠ²ΠΎΠ΄ Π·Π½Π°ΡΠ΅Π½ΠΈΡ Π² Memo).