Показать сообщение отдельно
  #3  
Старый 16.06.2010, 01:26
stervochka stervochka вне форума
Прохожий
 
Регистрация: 14.06.2010
Сообщения: 3
Репутация: 10
По умолчанию

Вывести на форму элементы матрицы А(5,5), находящиеся ниже главной и побочной диагонали одновременно. Элементы матрицы А формируются по правилу:
ai,j = 1/(i + j) - COS(i).




Код:
unit Unit1;

interface

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

type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
BitBtn1: TBitBtn;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,1]:='1';
StringGrid1.Cells[0,2]:='2';
StringGrid1.Cells[0,3]:='3';
StringGrid1.Cells[0,4]:='4';
StringGrid1.Cells[0,5]:='5';
StringGrid1.Cells[1,0]:='1';
StringGrid1.Cells[2,0]:='2';
StringGrid1.Cells[3,0]:='3';
StringGrid1.Cells[4,0]:='4';
StringGrid1.Cells[5,0]:='5';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
a:array[1..5,1..5] of real;
begin
for i:=1 to 5 do
for j:=1 to 5 do begin
a[i,j]:=(1/(i+j))-cos(i);
end;
for i:=1 to 5 do
for j:=1 to 5 do begin
if (i<j) then
StringGrid1.Cells[i,j]:=FloatToStr(a[i,j]);
end;
while i<=5 do begin
while j<=5 do begin
if (i>j) then StringGrid1.Cells[i,j]:=FloatToStr(a[i,j]);
i:=i+1;j:=j+2;
end;end;
end;

end.


что то тут не получаеться((((((
Ответить с цитированием