![]() |
|
|
|
|
#1
|
|||
|
|||
|
Здравствуйте ,алгоритм задания на картинке , подскажите в чем ошибка .
Код:
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.
Последний раз редактировалось qpmr, 24.05.2012 в 23:21. |
|
#2
|
||||
|
||||
|
Смотря каково её проявление.
|
|
#3
|
|||
|
|||
|
[Error] Unit1.pas(71): Statement expected, but expression of type 'Boolean' found
При задании условия .. |
|
#4
|
||||
|
||||
|
Код:
if (y(x0))*(y(x))>0 then (x1=x) and (y(x1)=y(x)) else
(x0=x) and (y(x0)=y(x)) ;Ну так конечно. And - логическа операция, а не объединение действий. ![]() Вообще смысл не очень понял. Перевожу написанное на русский язык: "Если y(x0)*y(x) больше 0 то (x1 равно x) ^ (y(x1) равно y(x)) иначе ..." Ну равно x и y(x1), компьютеру-то что делать? ![]() |
|
#5
|
||||
|
||||
|
предположу, что где-то тут, что-то не так...
Код:
if (y(x0))*(y(x))>0 then (x1=x) and (y(x1)=y(x)) else
(x0=x) and (y(x0)=y(x)) ;Код:
(x1=x) and (y(x1)=y(x)) Код:
(x0=x) and (y(x0)=y(x)) |
|
#6
|
|||
|
|||
|
так ведь в алгоритме именно так и написано ..
|
|
#7
|
||||
|
||||
|
Так надо отличать в алгоритме условия и нахождение значения переменных.
|