- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
StringGrid1: TStringGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a:array [0..9]of integer;
i:integer;
sum:integer;
begin
randomize;
for i:=0 to 9 do
begin
a[i]:=random (10)+1;
stringgrid1.cells[i,0]:=floattostr(a[i]);
end;
sum:=0;
begin
for i:=0 to 9 do
sum:=sum+a[i];
end;
edit1.text:=floattostr(sum);
end;
end.
Задача№11
Описать процедуру PowerA234(A, B, C, D), вычисляющую вторую, третью и четвертую степень числа A и возвращающую эти степени со- ответственно в переменных B, C и D (A — входной, B, C, D — выходные параметры; все параметры являются вещественными). С помощью этой процедуры найти вторую, третью и четвертую степень пяти данных чисел.
unit Unit2;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Edit2: TEdit;
Edit1: TEdit;
Label2: TLabel;
Label1: TLabel;
Edit3: TEdit;
Label3: TLabel;
Edit4: TEdit;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
i:integer;
A,B,C,D:real;
Procedure PowerA234(A:real; var B,C,D:real);
begin
B:=A*A;
C:=B*A;
D:=C*A;
end;
begin
a:=strtofloat(edit1.Text);
powerA234(A,B,C,D);
edit2.Text:=floattostr(B);
edit3.Text:=floattostr(C);
edit4.Text:=floattostr(D);
end;
end.
Задача№12
Описать процедуру SortInc3(A, B, C), меняющую содержимое пере- менных A, B, C таким образом, чтобы их значения оказались упорядочен- ными по возрастанию (A, B, C — вещественные параметры, являющиеся одновременно входными и выходными). С помощью этой процедуры упо- рядочить по возрастанию два данных набора из трех чисел: (A1, B1, C1) и (A2, B2, C2).
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
A1,B1,C1,A2,B2,C2:real;
Procedure SortDec3(var a,b,c:real);
begin
if b>c then begin c:=c+b;b:=c-b;c:=c-b;end;
if a>b then begin a:=a+b;b:=a-b;a:=a-b;end;
if b>c then begin c:=c+b;b:=c-b;c:=c-b;end;
end;
begin
a1:=strtofloat(edit1.Text);
b1:=strtofloat(edit2.Text);
c1:=strtofloat(edit3.Text);
SortDec3(A1, B1, C1);
edit4.Text:=floattostr(A1);
edit5.Text:=floattostr(B1);
edit6.Text:=floattostr(C1);
end;
end.
Задача№13
unit zadacha13;
