| 
			
			 
			
				12.12.2010, 15:17
			
			
			
		 | 
	| 
		
			
			| Прохожий |  | 
					Регистрация: 12.12.2010 Сообщения: 24
 Репутация: -20     |  | 
	| 
				 Перемножение матриц размерностью MxN NxQ 
 Помогите, пожалуйста, разобраться почему на запуск моей програмки выходит ошибка exception class EConvertError with message ''' is not a valid integer value'.  
Сама задача проста: перемножить матрицу А размерностью MxN на матрицу B размерностью NxQ.
 
Код программы:
 
	Admin:Код: procedure TForm1.Edit1Change(Sender: TObject);
var m:integer;
begin
if Edit1.Text<>'' then
begin
 m:=strtoint(Edit1.Text);
 StringGrid1.RowCount:=m;
 StringGrid3.RowCount:=m;
 StringGrid1.Visible:=true;
 StringGrid3.Visible:=true;
end
else
 begin
 StringGrid1.Visible:=false;
 StringGrid3.Visible:=false;
 end;
end;
procedure TForm1.Edit2Change(Sender: TObject);
var n: integer;
begin
if Edit2.Text<>'' then
begin
 n:=strtoint(Edit2.Text);
 StringGrid1.ColCount:=n;
 StringGrid2.RowCount:=n;
 Edit3.Text:=Edit2.Text ;
 StringGrid1.Visible:=true;
 StringGrid2.Visible:=true;
 end
else
 begin
 StringGrid1.Visible:=false;
 StringGrid2.Visible:=false;
 end;
end;
procedure TForm1.Edit4Change(Sender: TObject);
var q: integer;
begin
if Edit4.Text<>'' then
begin
 q:=strtoint(Edit4.Text);
 StringGrid2.ColCount:=q;
 StringGrid3.ColCount:=q;
 StringGrid2.Visible:=true;
 StringGrid3.Visible:=true;
end
else
 begin
 StringGrid2.Visible:=false;
 StringGrid3.Visible:=false;
 end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var a,b,x: array [0..100,0..100] of integer;
 i,j,l: integer;
 m,n,q:integer;
begin
// считываем матрицы с гридов
m:=StrToInt(Edit1.Text);
n:=StrToInt(Edit2.Text);
q:=StrToInt(Edit4.Text);
  for i:=1 to m do 
    for j:=1 to n do 
      a[i,j] := StrToInt(StringGrid1.Cells[i,j]);
  for i:=1 to n do 
    for j:=1 to q do 
       b[i,j] := StrToInt(StringGrid2.Cells[i,j]);
// перемножение матрицы
  For i:= 1 to m do
    For j:= 1 to q do
          Begin
          x[i,j]:=0;
           For l:= 1 to n do
           begin
             x[i,j]:=x[i,j]+a[l,i]*b[j,l];
           end;
           end;
// отображение матрицу в 3-ем гриде
   for i:=1 to m do
   begin
     for j:=1 to q do
     begin
     StringGrid3.cells[i,j]:=IntToStr(x[i,j]);
     end;
   end;
end;
end.  Пользуемся тегами!
			
			
			
			
				  |