Advertisement
AIwinter

4 lab

Feb 23rd, 2022
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.11 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Math, VclTee.TeeGDIPlus,
  8.   VCLTee.TeEngine, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     Button1: TButton;
  13.     Min: TEdit;
  14.     Max: TEdit;
  15.     Step: TEdit;
  16.     Label2: TLabel;
  17.     Label3: TLabel;
  18.     Label4: TLabel;
  19.     Label5: TLabel;
  20.     Memo1: TMemo;
  21.     Chart1: TChart;
  22.     Label7: TLabel;
  23.     Series1: TFastLineSeries;
  24.     procedure Button1Click(Sender: TObject);
  25.   private
  26.     { Private declarations }
  27.   public
  28.     { Public declarations }
  29.   end;
  30.  
  31. var
  32.   Form1: TForm1;
  33.  
  34. implementation
  35.  
  36. {$R *.dfm}
  37.  
  38. procedure TForm1.Button1Click(Sender: TObject);
  39. var a,b,y,h:double;
  40.       f:TextFile;
  41. begin
  42. Memo1.Clear;
  43. chart1.View3D := false;
  44.  
  45. if not trystrtofloat(stringreplace(Min.text,'.',',',[]),a) then
  46. begin
  47.   showmessage('Неверное мин знач');
  48.   Exit;
  49. end;
  50.  
  51. if not trystrtofloat(stringreplace(Max.text,'.',',',[]),b) then
  52. begin
  53.   showmessage('Неверное макс знач');
  54.   Exit;
  55. end;
  56.  
  57. if not trystrtofloat(stringreplace(Step.text,'.',',',[]),h) then
  58. begin
  59.   showmessage('Неверный шаг');
  60.   Exit;
  61. end;
  62.  
  63. if h<=0 then
  64. begin
  65.   showmessage('Неверный шаг');
  66.   Exit;
  67. end;
  68.  
  69. if a>b then
  70. begin
  71.   showmessage('Макс. значение меньше мин.');
  72.   Exit;
  73. end;
  74.  
  75. AssignFile(f, 'OUTPUT.txt');
  76. Rewrite(f);
  77. Memo1.lines.add('x      y');
  78. chart1.ClearChart();
  79. chart1.AddSeries(TFastLineSeries);
  80. chart1.series[0].Color := clBlack;
  81.  
  82. while a<=b do
  83.   begin
  84.     if a>=0 then
  85.     begin
  86.       y:=SimpleRoundTo(Power(a,6.5)/exp(Cos(a)),-3);
  87.       Memo1.lines.add(FloatToStr(a)+'      '+FloatToStr(y));
  88.       writeln(f,floattostr(a)+'  '+floattostr(y));
  89.       chart1.series[0].AddXY(a,y);
  90.     end
  91.     else
  92.     begin
  93.       chart1.View3D := false;
  94.       Memo1.lines.add(floattostr(a)+'      -');
  95.       writeln(f,floattostr(a)+'  -');
  96.     end;
  97.   a:=SimpleRoundTo((a+h),-3);
  98.   end;
  99.  
  100. closefile(f);
  101. end;
  102. end.
  103.  
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement