Создал массив с помощью рандома но он выдает какие то запредельные цифры,не подскажите почему?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Buttons;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Label1: TLabel;
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
x:array[1..3,1..3] of integer;
i,j:integer;
begin
randomize;
for i:=1 to 3 do
for j:=1 to 3 do
x[i,j]:=random(10);
for i:=0 to 2 do
for j:=0 to 2 do
StringGrid1.Cells[i,j]:=IntToStr(x[i,j]);
end;
end.
for i:=0 to 2 do
for j:=0 to 2 do
StringGrid1.Cells[i,j]:=IntToStr(x[i,j]);
Попробуй так
неа,он выводит в стринг грит все элементы кроме 1 столбца и первой строки
а так?
for i:=1 to 3 do
for j:=1 to 3 do
begin
x[i,j]:=random(10);
StringGrid1.Cells[j-1,i-1]:=IntToStr(x[i,j]);
end;
Вот так да работает,спасибо!