Приложение А
(обязательное)
Листинг программы TSO
unit Kurs_p;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit1: TEdit;
Label9: TLabel;
Edit2: TEdit;
Label10: TLabel;
Edit3: TEdit;
Label11: TLabel;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
public
procedure OsiK (x0,y0:Integer);
procedure Postroenie(T1,T2,R1,R2:real);
end;
var
Form1: TForm1;
X0,Y0:integer;
T1,T2,R1,R2:real;
implementation
{$R *.DFM}
procedure TForm1.OsiK (x0,y0:Integer);
var
i,x,y:integer;
begin
Canvas.Pen.Width:=2;
Canvas.Pen.Color := clBlack;
Canvas.MoveTo(x0, y0); {построение оси X}
Canvas.LineTo(x0+400, y0);
Canvas.MoveTo(x0+400, y0); {построение стрелочек оси Х}
Canvas.LineTo(x0+400-10, y0-5);
Canvas.MoveTo(x0+400, y0);
Canvas.LineTo(x0+400-10, y0+5);
Label4.Left:=x0+390;
Label4.Top:=y0+10;
Label5.Left:=x0+350;
Label5.Top:=y0+10;
Label6.Left:=x0;
Label6.Top:=y0+10;
Label7.Left:=x0-25;
Label7.Top:=y0-10;
Label8.Left:=x0-25;
Label8.Top:=y0-105;
Canvas.MoveTo(x0, y0); {построение оси Y}
Canvas.LineTo(x0, y0-150);
Canvas.MoveTo(x0, y0-150); {построение стрелочек оси Y}
Canvas.LineTo(x0-5, y0-150+10);
Canvas.MoveTo(x0, y0-150);
Canvas.LineTo(x0+5, y0-150+10);
Label3.Left:=x0-25;
Label3.Top:=y0-150;
Canvas.Pen.Width:=1;
x:=x0;
for i:=1 to 10 do
begin
x:=x+35;
Canvas.MoveTo(x, y0-3);
Canvas.LineTo(x, y0+3);
end;
y:=y0;
for i:=1 to 5 do
begin
y:=y-20;
Canvas.MoveTo(x0-3, y);
Canvas.LineTo(x0+3, y);
end;
end;
procedure TForm1.Postroenie(T1,T2,R1,R2:real);
var
x,y:integer;
Kx,Ky,x1,y1,P,C1,Sag:real;
begin
Canvas.Pen.Width:=1;
Canvas.Pen.Color := clRed;
Sag:=(R2-R1)/500; {шаг по X}
C1:=(T1-T2)/(ln(R2/R1));
Kx:=(R2-R1)/350; {Коэффициенты "усиления"}
if T1>T2 then
Ky:=T1/100
else
Ky:=T2/100;
x1:=R1; {Начальные условия}
y1:=T1;
Canvas.MoveTo(x0+Round((x1-R1)/Kx),y0-Round(y1/Ky));
repeat
y:=Round(y1/Ky);
x:=Round((x1-R1)/Kx);
Canvas.LineTo(x0+x, y0-y);
x1:=x1+Sag;
y1:=(T1+C1*ln(R1/x1));
{label1.Caption:=label1.Caption+'; '+intToStr(x);
label2.Caption:=label2.Caption+'; '+intToStr(y);}
until x1>R2;
P:=4*Pi*C1;
label1.Caption:='Мощность источника: ='+FloatToStrF(P,ffGeneral,5,1)+
' Вт';
label5.Caption:=FloatToStrF(R2,ffGeneral,4,1);
label6.Caption:=FloatToStrF(R1,ffGeneral,4,1);
if T1>T2 then
begin
label7.Caption:=FloatToStrF(T2,ffGeneral,4,1);
label8.Caption:=FloatToStrF(T1,ffGeneral,4,1);
end
else
begin
label7.Caption:=FloatToStrF(T1,ffGeneral,4,1);
label8.Caption:=FloatToStrF(T2,ffGeneral,4,1);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Code1,Code2,Code3,Code4:integer;
begin
Repaint;
val (Edit1.Text,T1,Code1);
val (Edit2.Text,T2,Code2);
val (Edit3.Text,R1,Code3);
val (Edit4.Text,R2,Code4);
if (Code4 or Code3 or Code2 or Code1) <> 0 then
begin
Edit1.SetFocus;
MessageDlg ('Введите пожалуйста значение!', mtError, [mbOk],0);
end
else
Postroenie(T1,T2,R1,R2);
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
x0:=100;
y0:=200;
OsiK(x0,y0);
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',#8,'.']) then
begin
Key:=#0;
MessageBeep($FFFFFFFF);
end;
end;
end.