
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •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)
StringGrid1: TStringGrid;
Button1: TButton;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Button2: TButton;
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
A,B,C,D,F,E,G,H:integer;
p,q:integer;
function NOD2(A,B:integer):integer;
begin
while (A <> 0)and(B <> 0) do
begin
if A >= B then A:= A mod B
else B:= B mod A;
end;
NOD2:=A+B;
end;
procedure Frac1(A,B:integer; var p,q:integer);
begin
p:=A div NOD2(A,B);
q:=B div NOD2(A,B);
if q<0 then begin p:=p*-1; q:=q*-1;end;
end;
var z:array[0..7] of integer;
i:integer;
begin
for i:=0 to 7 do
z[i]:=strtoint(stringgrid1.cells[i,1]);
a:=z[0];
b:=z[1];
c:=z[2];
d:=z[3];
f:=z[4];
e:=z[5];
g:=z[6];
h:=z[7];
Frac1(d*A+C*b,b*d,p,q);
edit1.Text:=inttostr(a)+'/'+inttostr(b)+'+'+inttostr(c)+'/'+inttostr(d)+'='+inttostr(p)+'/'+inttostr(q);
Frac1(f*A+e*b,b*f,p,q);
edit2.Text:=inttostr(a)+'/'+inttostr(b)+'+'+inttostr(e)+'/'+inttostr(f)+'='+inttostr(e)+'/'+inttostr(f);
Frac1(h*A+g*b,b*h,p,q);
edit3.Text:=inttostr(a)+'/'+inttostr(b)+'+'+inttostr(g)+'/'+inttostr(h)+'='+inttostr(g)+'/'+inttostr(h);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
stringgrid1.Cells[0,0]:='A';
stringgrid1.Cells[1,0]:='B';
stringgrid1.Cells[2,0]:='C';
stringgrid1.Cells[3,0]:='D';
stringgrid1.Cells[4,0]:='F';
stringgrid1.Cells[5,0]:='E';
stringgrid1.Cells[6,0]:='G';
stringgrid1.Cells[7,0]:='H';
end; end.
Задача№14
Дано целое число N и набор из N целых чисел. Найти номер перво- го экстремального (то есть минимального или максимального) элемента из данного набора.
unit zadacha14;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm2 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var a:array[0..9] of integer;
otvet,i,max,min,maxi,mini:integer;
begin
randomize;
for I := 0 to 9 do
begin
a[i]:=random (45)+12;
stringgrid1.Cells[i,0]:=floattostr(a[i]);
end;
maxi:=0;
mini:=0;
max:=a[0];
min:=a[0];
for i:=0 to 9 do
begin
if max>a[i] then
begin
max:=a[i]; maxi:=i;
end;
if min<a[i] then
begin
min:=a[i]; mini:=i;
end;
end;
if maxi>mini then otvet:=mini else otvet:=maxi;
edit1.Text:=floattostr(otvet);
end;
end.
Задача№15
Дан целочисленный массив размера N. Вывести вначале все содержа- щиеся в данном массиве четные числа в порядке возрастания их индексов, а затем — все нечетные числа в порядке убывания их индексов.
unit zadacha15;