- •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)
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 i:integer;
begin
with stringgrid1 do
for i :=0 to ColCount - 1 do
cols[i].clear;
end;
procedure TForm1.ВычислитьClick(Sender: TObject);
var a:array[0..4] of integer;
i:integer;
begin
randomize;
For i:=0 to 4 do
begin
a[i]:=Random(101)-50;
stringgrid1.cells[i,0]:=floattostr(a[i]);
end;
For i:=0 to 4 do
If a[i] mod 2=0 then
stringgrid1.cells[i,1]:=floattostr(a[i]);
For i:=4 Downto 0 do
If a[i] mod 2<>0 then
stringgrid1.cells[i,2]:=floattostr(a[i]);
end;
end.
Задача№19
Дан массив размера N, все элементы которого, кроме последнего, упорядочены по возрастанию. Сделать массив упорядоченным, переме- стив последний элемент на новую позицию.
unit zadacha19;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
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 [1..10] of integer;
n,j,i:integer;
begin
for i:=1 to 10 do begin
a[i]:=strtoint(stringgrid1.Cells[i,0]);
end;
n:=10;
j:=1;
for i:=2 to n do
begin
if (a[j]<>a[i]) then begin
inc(j);
a[j]:=a[i];
end;
end;
n:=j;
for i:=1 to n do
stringgrid1.Cells[i,1]:=floattostr(a[i]);
end;
end.
Задача№20
unit zadacha20;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
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;
v,cncl_ms,j,max,temp,N,i:integer;
begin
n:=9;
randomize;
for i:=0 to n do begin
a[i]:=random(10)+1;
stringgrid1.Cells[i,0]:=inttostr(a[i]);
end;
cncl_ms:=n;
for i:=0 to n do
begin
max:=0;
for j:=0 to cncl_ms do
begin
if a[j]>a[max] then begin max:=j;end;
end;
temp:=a[max];
a[max]:=a[cncl_ms];
a[cncl_ms]:=temp;
dec(cncl_ms); end;
for i:=0 to n do
stringgrid1.Cells[i,1]:=inttostr(a[i]);
end;
end.
Задача№27
Дан символ C, изображающий цифру или букву (латинскую или рус- скую). Если C изображает цифру, то вывести строку «digit», если латин- скую букву — вывести строку «lat», если русскую — вывести строку «rus».
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
