//Композиція
for i:=1 to 5 do
for j:=1 to 5 do
if i<>j then
begin
if form1.strngrd_comp.Cells[i-1,j-1]='1' then
begin
if i=1 then begin p1x:=67; p1y:=8; end;
if i=2 then begin p1x:=125; p1y:=49; end;
if i=3 then begin p1x:=104; p1y:=117; end;
if i=4 then begin p1x:=30; p1y:=117; end;
if i=5 then begin p1x:=10; p1y:=49; end;
if j=1 then begin p2x:=67; p2y:=8; end;
if j=2 then begin p2x:=125; p2y:=49; end;
if j=3 then begin p2x:=104; p2y:=117; end;
if j=4 then begin p2x:=30; p2y:=117; end;
if j=5 then begin p2x:=10; p2y:=49; end;
DrawArrow(Form1.Img_comp.Canvas,p1x,p1y,p2x,p2y,2);
end;
end
else
if form1.strngrd_comp.cells[i-1,j-1]='1' then
begin
if i=1 then begin p1x:=67; p1y:=4; end;
if i=2 then begin p1x:=129; p1y:=49; end;
if i=3 then begin p1x:=104; p1y:=121; end;
if i=4 then begin p1x:=30; p1y:=121; end;
if i=5 then begin p1x:=6; p1y:=49; end;
form1.Img_comp.Canvas.Ellipse(p1x+4,p1y+4,p1x-4,p1y-4);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var check1,check2:Boolean;
begin
check1:=True;
check2:=true;
for i:=0 to Form1.strngrd1.ColCount-1 do
for j:=0 to Form1.strngrd1.RowCount-1 do
if Form1.strngrd1.Cells[i,j]='' then check1:=False;
for i:=0 to Form1.strngrd2.ColCount-1 do
for j:=0 to Form1.strngrd2.RowCount-1 do
if Form1.strngrd2.Cells[i,j]='' then check2:=False;
if (check1=false) and (check2=True) then ShowMessage('Перевірте задання першого відношення!')
else if (check1=true) and (check2=false) then ShowMessage('Перевірте задання другого відношення!')
else if (check1=false) and (check2=false) then ShowMessage('Перевірте задання обох відношень!')
else Calculate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if FileExists('val1.dat') then
begin
AssignFile(values1,'val1.dat');
Reset(values1);
for i:=1 to 5 do
for j:=1 to 5 do
Readln(values1,R1[i,j]);
CloseFile(values1);
for i:=1 to 5 do
for j:=1 to 5 do
Form1.strngrd1.Cells[i-1,j-1]:=R1[i,j];
end;
if FileExists('val2.dat') then
begin
AssignFile(values2,'val2.dat');
Reset(values2);
for i:=1 to 5 do
for j:=1 to 5 do
Readln(values2,R2[i,j]);
CloseFile(values2);
for i:=1 to 5 do
for j:=1 to 5 do
Form1.strngrd2.Cells[i-1,j-1]:=R2[i,j];
end;
end;
procedure TForm1.FormCanResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
begin
resize:=false;
end;
end.
Результат роботи програми:
