Помогите доделать код unit proect; {$mode objfpc}{$H+} interface uses Classes, SysUtils,...

0 голосов
69 просмотров

Помогите доделать код
unit proect;

{$mode objfpc}{$H+}

interface
uses
Classes, SysUtils, FileUtil, TAGraph, TASeries,Forms,
Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;

type

{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Chart1: TChart;
Image5: TImage;
Image6: TImage;
Label14: TLabel;
Label15: TLabel;
SinSeries2: TLineSeries;
CosSeries2: TLineSeries;
Edit3: TEdit;
Edit4: TEdit;
Edit1: TEdit;
Edit2: TEdit;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Shape1: TShape;
SinSeries: TLineSeries;
CosSeries: TLineSeries;
SinCosSeries: TLineSeries;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;


implementation

{$R *.lfm}

{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
const
N = 100;
MIN = -5;
MAX = 5;
var
x: Double;
a,b,c,d,i: Integer;
begin
//чистка предыдущих графиков
//считываем переменные с клавиатуры
a:=StrToInt(Edit1.Text);
b:=StrToInt(Edit2.Text);
c:=StrToInt(Edit3.Text);
d:=StrToInt(Edit4.Text);
for i:=0 to N-1 do
begin
//Задаем для графиков площадь
x := MIN + (MAX - MIN) * i /(N - 1);
//Рисуем графики
SinSeries.AddXY(x, (a*x+b));
CosSeries.AddXY(x, (d*x*x));
SinCosSeries.AddXY(x,(c/x));
SinSeries2.AddXY(x, sin(x));
CosSeries2.AddXY(x, cos(x));
end;
end.
ошибка: Fatal: Syntax error, "BEGIN" expected but "end of file" found
Lazarus.


Информатика (132 баллов) | 69 просмотров
0

а че сделать то надо? какое задание? может у вас там вообще все не правильно

0

нет одного закрывающего end? для implementation наверное

Дан 1 ответ
0 голосов
Правильный ответ

Unit proect;

{$mode objfpc}{$H+}

interface
uses
Classes, SysUtils, FileUtil, TAGraph, TASeries,Forms,
Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;

type
    
    { TForm1 }
    TForm1 = class(TForm)
        Button1: TButton;
        Chart1: TChart;
        Image5: TImage;
        Image6: TImage;
        Label14: TLabel;
        Label15: TLabel;
        SinSeries2: TLineSeries;
        CosSeries2: TLineSeries;
        Edit3: TEdit;
        Edit4: TEdit;
        Edit1: TEdit;
        Edit2: TEdit;
        Image1: TImage;
        Image2: TImage;
        Image3: TImage;
        Image4: TImage;
        Label1: TLabel;
        Label10: TLabel;
        Label11: TLabel;
        Label12: TLabel;
        Label13: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Label7: TLabel;
        Label8: TLabel;
        Label9: TLabel;
        Shape1: TShape;
        SinSeries: TLineSeries;
        CosSeries: TLineSeries;
        SinCosSeries: TLineSeries;
        procedure Button1Click(Sender: TObject);
    private
    { private declarations }
    public
    { public declarations }
    end;

var
    Form1: TForm1;


implementation

{$R *.lfm}

{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
const
    N = 100;
    MIN = -5;
    MAX = 5;
var
    x, step: Double;
    a, b, c, d, i: Integer;
begin
    //чистка предыдущих графиков
    //считываем переменные
    a := StrToInt(Edit1.Text);
    b := StrToInt(Edit2.Text);
    c := StrToInt(Edit3.Text);
    d := StrToInt(Edit4.Text);
    
    step := (MAX - MIN) / N;
    x := MIN;
    
    repeat
        //Рисуем графики
        SinSeries.AddXY(x, a * x + b);
        CosSeries.AddXY(x, d * x * x);
        SinCosSeries.AddXY(x, c / x);
        SinSeries2.AddXY(x, sin(x));
        CosSeries2.AddXY(x, cos(x));
        //следующий
        x := x + step;
    until x > MAX;
end;
end.

(55.0k баллов)
0

вот, кое что переделала, синтаксис правильный, а запускать у меня не на чем. Так что если что то пишите

0

и вообще тут правильнее задать величину шага, чем кол-во точек