Код:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids;
type
TForm1 = class(TForm)
SG1: TStringGrid;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
j, m ,x, k: Integer;
a,b:array[1..5]of integer;
i:byte;
s1,s2:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
for i:=1 to 5 do
if Length(SG1.Cells[i-1, 0]) <>0
then a[i] := StrToInt(SG1.Cells[i-1,0])
else a[i] := 0;
{сортируем массив а}
for i := 1 to 4 do
begin
m := i;
x := A[i];
for j := i + 1 to 5 do
if x > A[j] then
begin
m := j;
x := A[j];
end;
A[m] := A[i];
A[i] := x;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
for i:=1 to 5 do
if Length(SG1.Cells[i-1, 0]) <>0
then b[i] := StrToInt(SG1.Cells[i-1,0])
else b[i] := 0;
{сортируем массив b}
for i := 1 to 4 do
begin
m := i;
x := b[i];
for j := i + 1 to 5 do
if x > b[j] then
begin
m := j;
x := b[j];
end;
b[m] := b[i];
b[i] := x;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
k:=0;
for i:=1 to 5 do
if a[i]=b[i] then inc(k);
if k=5 then form1.Panel1.Caption:=' Можно '
else form1.Panel1.Caption:=' Нельзя '
end;
end.
Я сделал со StringGrid вот так. Кнопка 1 для ввода 1-го массива, кнопка 2 для ввода 2 массива, кнопка 3 для выдачи результата.