![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Ошибку выбивает в выделенной строке
Код:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const n=5;
implementation
{$R *.dfm}
Type Matrix=array [1..5,1..5] of real;
vect= array[1..5]of integer;
Var a:matrix;
s:real;
procedure TForm1.Button1Click(Sender: TObject);
var sm,smax,sd:string;
j, i,ier,imax,jmax:integer; max:real;
begin
for i:= 1 to 5 do if Length(Stringgrid1.Cells[i-1,0])<>0
then a[i]:= strtofloat(stringgrid1.Cells[i-1,0]) else a[i,j]:=0;
for i:=1 to n do
begin
s:=0;
for j:=1 to n do
s:=s+strtofloat(StringGrid1.cells[j,i]);
strtofloat(stringgrid1.cells[n-j+1,j]);
stringgrid2.cells[i,1]:=floattostr(s);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var j, i:integer;begin for i:=1 to n do
for j:=1 to n do
stringgrid1.cells[j,i]:=' ' ;
for j:=1 to 5 do
stringgrid2.cells[j-1,1]:=' ';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
end.Последний раз редактировалось Grynyuk, 21.05.2013 в 23:15. |
|
#2
|
||||
|
||||
|
А какую еще ошибку можно ожидать, если пытаться присвоить массиву число?
|
| Этот пользователь сказал Спасибо Bargest за это полезное сообщение: | ||
Grynyuk (22.05.2013)
| ||
|
#3
|
||||
|
||||
|
В какой строке ошибка, в 43?
Код:
else a[i,j]:=0; Код:
a[i]:= strtofloat(stringgrid1.Cells[i-1,0]) else a[i,j]:=0; |
| Этот пользователь сказал Спасибо angvelem за это полезное сообщение: | ||
Grynyuk (22.05.2013)
| ||
|
#4
|
|||
|
|||
|
Спасибо помогло но теперь не могу установить курсор в ячейку стринггрид1 чтобы задать массив
Код:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const n=5;
implementation
{$R *.dfm}
Type Matrix=array [1..5,1..5] of real;
vect= array[1..5]of integer;
Var a:matrix;
s:real;
procedure TForm1.Button1Click(Sender: TObject);
var sm,smax,sd:string;
j, i,ier,imax,jmax:integer; max:real;
begin
for j:=1 to 5 do begin
for i:= 1 to 5 do if Length(Stringgrid1.Cells[i-1,0])<>0 then a[i,1]:= strtofloat(stringgrid1.Cells[i-1,0]) else a[i,j]:=0;
end;
for i:=1 to n do
begin
s:=0;
for j:=1 to n do
s:=s+strtofloat(StringGrid1.cells[j,i]);
strtofloat(stringgrid1.cells[n-j+1,j]);
stringgrid2.cells[i,1]:=floattostr(s);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var j, i:integer;begin for i:=1 to n do
for j:=1 to n do
stringgrid1.cells[j,i]:=' ' ;
for j:=1 to 5 do
stringgrid2.cells[j-1,1]:=' ';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
end.Последний раз редактировалось M.A.D.M.A.N., 22.05.2013 в 08:13. |
|
#5
|
||||
|
||||
|
Цитата:
|