Показать сообщение отдельно
  #1  
Старый 24.05.2012, 22:57
qpmr qpmr вне форума
Прохожий
 
Регистрация: 12.12.2011
Сообщения: 27
Репутация: 10
По умолчанию Нахождение корней

Здравствуйте ,алгоритм задания на картинке , подскажите в чем ошибка .

Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, TeeProcs, TeEngine, Chart, Series;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    BitBtn1: TBitBtn;
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Series1: TLineSeries;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

type
t=function(x:extended):extended ;
function y(x:extended):extended;
begin
y:=2*x*x+x;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.clear;
edit2.clear;
edit3.clear;
edit4.clear;
label5.caption:='';
end;

procedure TForm1.Button1Click(Sender: TObject);
var x1,x0,a,b,shag,c,pog,x:extended; 
begin
  a:=strtofloat(edit1.text);
  b:=strtofloat(edit2.text);
  shag:=strtofloat(edit3.text);
  pog:=strtofloat(edit4.text);
    series1.clear;
    x0:=a;  x1:=b;
    x:=(x0+x1)/2;
    repeat
    series1.AddXY(x0,y(x0),'',clblue);
    x0:=x0+0.1;   // шаг
    repeat
    series1.AddXY(x1,y(x1),'',clred);
     x1:=x1+0.1;
    if (y(x0))*(y(x))>0 then  (x1=x)  else
     (x0=x)  ;

     c:=(x0+x1)/2;
     label5.caption:=+floattostr(c);
     until (x1-x0)<0.000000001 ;
end;
       end.
Изображения
Тип файла: jpg 22.JPG (84.0 Кбайт, 19 просмотров)
Ответить с цитированием