не знаю что изменить в коде чтобы программа работала правильно.
Задание: Составьте программу, проверяющую, можно ли, меняя местами элементы одномерного массива А, получить целочисленный массив В.
Текст программы
PHP код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Label1: TLabel;
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var n: integer;
begin
n:=StrToInt(Edit1.Text);
StringGrid1.RowCount:=n;
StringGrid2.RowCount:=n;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i,j,n,s:integer;
begin
n:=StrToInt(Edit1.Text);
s:=0;
for i:=1 to n do
for j:=1 to n do
begin
if (StringGrid1.Cells[0,i]=StringGrid2.Cells[0,j]) then s:=s+1;
end;
label2.Caption:=IntToStr(s);
if s=n then label1.caption:='можно' else label1.Caption:='нельзя'
end;
end.