Здравствуйте. Помогите, пожалуйста, разобраться.
1.Создать проект, в котором объявить переменные различных типов, присвоить переменным A и B значения, переменным разных типов C, D и F присвоить значения арифметического выражения A/B, вывести значения переменных C, D и F.
Вот собственно код который сделал:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
A,B:byte;
C:single;
D:real;
F:double
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
A:=1;
B:=3;
C:=A/B
D:=A/B
F:=A/B
Label1.Caption:=floatToStr(C);
Label2.Caption:=floatToStr(D);
Label3.Caption:=floatToStr(F);
end;
end.
Выдает ошибку: implementation
Заранее, спасибо за помощь
Проект "Переменные"
Модератор: Модераторы
C:=A/B
А кто будет
C:=A/B;
А кто будет
C:=A/B;
Поправил на:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
a,b:byte;
c:single;
d:real;
f:double
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
A:=1;
B:=3;
C:=A/B;
D:=A/B;
F:=A/B;
Label1.Caption:=floatToStr(C);
Label2.Caption:=floatToStr(D);
Label3.Caption:=floatToStr(F);
end;
end.
Выдает ошибку:
unit1.pas(34,1) Error: ожидается ;, но найдено implementation
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
a,b:byte;
c:single;
d:real;
f:double
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
A:=1;
B:=3;
C:=A/B;
D:=A/B;
F:=A/B;
Label1.Caption:=floatToStr(C);
Label2.Caption:=floatToStr(D);
Label3.Caption:=floatToStr(F);
end;
end.
Выдает ошибку:
unit1.pas(34,1) Error: ожидается ;, но найдено implementation
А кто будет
здесь ставить точку с запятой? Компилятор же явно пишет: надо поставить ";". Хоть в следующей строке - но надо. А уже потом можно и implementation.
stan-86 писал(а):f:double
здесь ставить точку с запятой? Компилятор же явно пишет: надо поставить ";". Хоть в следующей строке - но надо. А уже потом можно и implementation.
Все заработало!!!!! Спасибо огромное!!!
p.s. Не используйте тип Real, он только для совместимости в DOS Borland Pascal.
