Добавил:
Fragga
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:PascalDelphi / Многие готовые лабы за 1&2 сем. от Колесниковой М.Д. / L3Pr2 / Unit1
.pas unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var M,N,NOD,NOK:word;
i,k:word;
begin
M:=StrToInt(Edit1.text);N:=StrToInt(Edit2.text);
if N>M then k:=M else k:=N;
NOD:=1;
for i:=1 to k do
if (N mod i=0) and (M mod i=0) then NOD:=i;
NOK:=NOD*(N div NOD)*(M div NOD);
Label4.Caption:='NOD='+IntToStr(NOD);
Label5.Caption:='NOK='+IntToStr(NOK)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var M,N,NOD,NOK:word;
i,k:word;
begin
M:=StrToInt(Edit1.text);N:=StrToInt(Edit2.text);
if N>M then k:=M else k:=N;
NOD:=1;
for i:=1 to k do
if (N mod i=0) and (M mod i=0) then NOD:=i;
NOK:=NOD*(N div NOD)*(M div NOD);
Label4.Caption:='NOD='+IntToStr(NOD);
Label5.Caption:='NOK='+IntToStr(NOK)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;
end.