Code
Uses CRT;
Const
Vertex: String = 'abcdefghijklmnop';
Var n: Byte;
i,j: Byte;
a: Array[1..20, 1..20] of Byte;
Procedure PrintMatrix;
Var i,j: Byte;
Begin
ClrScr;
For i := 1 to n do
Begin
For j := 1 to n do
Write(a[i,j]:5);
Writeln;
End;
ReadKey;
End;
Begin
ClrScr;
Write('Num of vertex: '); Readln(n);
Writeln;
Writeln('Input matrix: [0] - no link or [N] - link');
Writeln('e.g.: "a -> b: 0" -- mean, that ver.A not linked with ver.B');
Writeln('e.g.: "b -> d: 4" -- mean, that ver.B linked with ver.D by 4-th line');
Writeln;
For i := 1 to n do
Begin
For j := 1 to n do
Begin
Write(Vertex[i],' -> ', Vertex[j],': '); Readln(a[i,j]);
End;
End;
Writeln('Printing matrix');
ReadKey;
PrintMatrix;
Writeln('Search the loop''s');
For i := 1 to n do
Begin
if (a[i,i] <> 0) then Writeln('Loop in: ',Vertex[i]);
End;
Readkey;
End.