| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, ExtCtrls,StdCtrls,Math,Series, ValEdit, jpeg, TeEngine, TeeProcs, Chart;
type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Button1: TButton; Chart1: TChart; Series1: TLineSeries; Label8: TLabel; Label9: TLabel; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Label10: TLabel; Label11: TLabel; Label12: TLabel; Edit11: TEdit; Edit12: TEdit; Button2: TButton; Edit13: TEdit; Edit14: TEdit; Label13: TLabel; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private aY,pY,cY,aX,aP,aC: array of real; function funY(x: Real): Real;
{ Private declarations } public { Public declarations } end;
var Form1: TForm1; Hx,Hy,y,H,a0,a1,a2,a3,a4,Ymax,Ymin,Xmax,Xmin,x,Int:real;
implementation
{$R *.dfm} function TForm1.funY(x: Real): Real; begin Result:=a0+a1*x+a2*power(x,2)+a3*power(x,3)+ a4*power(x,4) end; procedure TForm1.FormCreate(Sender: TObject); begin try
Xmax:=StrToFloat(Edit7.Text); Xmin:=StrToFloat(Edit6.Text);
Ymax:=StrToFloat(Edit11.Text); Ymin:=StrToFloat(Edit12.Text);
Hx:=StrToFloat(Edit8.Text); Hy:=StrToFloat(Edit9.Text); H:=StrToFloat(Edit10.Text); except MessageBeep(Error); MessageDlg('Неверно заданы параметры', mtError, [mbOk], 0); end; Chart1.BottomAxis.Minimum:=Xmin; Chart1.BottomAxis.Maximum:=Xmax;
Chart1.LeftAxis.Minimum:=Ymin; Chart1.LeftAxis.Maximum:=Ymax;
Chart1.BottomAxis.Increment:=Hx; Chart1.LeftAxis.Increment:=Hy;
Form1.Button1Click(Sender); end;
procedure TForm1.Button1Click(Sender: TObject); begin Series1.Clear; x:=Xmin; a0:=StrToFloat(Edit1.Text); a1:=StrToFloat(Edit2.Text); a2:=StrToFloat(Edit3.Text); a3:=StrToFloat(Edit4.Text); a4:=StrToFloat(Edit5.Text); While x<=Xmax do begin y:=(a0+a1*x+a2*power(x,2)+a3*power(x,3)+ a4*power(x,4)); Series1.AddXY(x, y, '', clTeeColor); x:=x+h; end; ShowMessage ('введите пожалуйста в поле ввода n(n=(Xmax-Xmin)/h)'); end;
procedure TForm1.Button2Click(Sender: TObject);
Var n,i:integer; SUMcY,SUMpY,SUM,h,S,T,U:real;
begin x:=Xmin; n:=StrToInt(Edit14.Text); H:=StrToFloat(Edit10.Text); For i:=1 to n do begin aX[i]:= x + (i-1)*h; aY[i]:= funY(aX[i]); end; x:=Xmin; For i:=1 to n do begin aP[i]:= x + i*h; pY[i]:= funY(aP[i]); end; x:=Xmin; For i:=1 to n do begin aC[i]:= x + (i-1)*h + h/2; cY[i]:= funY(aC[i]) ; end; S:=0; For i:=1 to n do begin S:=S+aY[i]; SUM:=S; end; T:=0; For i:=1 to n do begin T:=T+pY[i]; SUMpY:=T; end; U:=0; For i:=1 to n do begin U:=U+cY[i]; SUMcY:=U; end; Int:=1/6*(SUM + SUMpY + 4*SUMcY)*h; Edit13.Text:=FloatToStr(Int); [color=blue] \\ вот тут результат не выводит[/color] end;
end.
|
Ввожу на форму параметр n, жму кнопку для вывода результата для Int в Edit13, выдает вот это:
Debugger Exception Notification
Project Project1.exe raised exception class EAccess Violation with message 'Access violation at address 0048B5D3 in module ' Project1.exe.' Write of address 00000008'. Process stopped.Use Step or Run to continue.
Я жму дальше Run, выходит такая табличка:
Project1 Access violation at address 0048B5D3 in module 'Project1.exe'. Write of address 00000008.
Знающие люди прощу помощи, мне нужно только чтобы результат расчета выводился в Edit13. С Delphi очень редко встречаюсь, заранее спасибо. |