Скачиваний:
7
Добавлен:
15.06.2014
Размер:
1.88 Кб
Скачать
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, Buttons, StdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
BitBtn1: TBitBtn;
StringGrid1: TStringGrid;
Button3: TButton;
StringGrid2: TStringGrid;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
A,B:array of integer;
N,i,j:integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
N:=5; Edit1.Text:=inttostr(N);
StringGrid1.ColCount:=N+1;
StringGrid2.ColCount:=N+1;
StringGrid1.Cells[0,0]:=' A'; //называем таблицы
StringGrid2.Cells[0,0]:=' T';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N+1;
StringGrid2.ColCount:=N+1;
StringGrid1.Cells[0,0]:=' A';
StringGrid2.Cells[0,0]:=' T';
end;

procedure TForm1.Button3Click(Sender: TObject);
var t:integer;
begin
//выделяем нужный для записи первого массива объем памяти
SetLength(a,n+1);
//чтение данных из таблицы в массив
for i:=1 to N do
A[i]:=StrToInt(StringGrid1.Cells[i,0]);

for i:=1 to (n div 2) do
begin
t:=a[i];
a[i]:=a[n-i+1];
a[n-i+1]:=t;
end;

//Вывод результата:
for i:=1 to n do
Stringgrid2.Cells[i,0]:=inttostr(a[i]);
//Освобождение памяти, занимаемой динамическим массивом
a:=nil;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
randomize;
for i:=1 to n do
stringgrid1.Cells[i,0]:=inttostr(random(100));
end;

end.

Соседние файлы в папке 5.1
  • #
    15.06.2014188 б7Project1.dpr
  • #
    15.06.2014876 б8Project1.res
  • #
    15.06.20146.15 Кб7Unit1.dcu
  • #
    15.06.201451 б7Unit1.ddp
  • #
    15.06.20143.54 Кб7Unit1.dfm
  • #
    15.06.20141.88 Кб7Unit1.pas