Napisać program (język dowolny) umożliwiający symulację układów przełączających zbudowanych z włączników. Program powinien wykorzystywać stałe, typy i tablice

o to moj kod

program symulator;
uses
crt;
const
N=7;
type
wlacznik = record
we: boolean;
st: boolean;
wy: boolean;
end;

var
uklad: array[1..N] of wlacznik;
topo : array[1..N,1..N] of boolean;
kc: char;
ki, i,k: integer;

function b2c(stan: boolean): char;
begin
if (stan) then
b2c :='T'
else
b2c :='N';
end;

procedure simulate;
begin
for i:=1 to n do
begin
if (uklad[i].we=true) and (uklad[i].st=true) then
uklad[i].wy:=true
else
uklad[i].wy:=false;
for k:=1 to n do
begin

if (topo[i,k]=true) and (uklad[i].wy=true) then
uklad[k].we:=uklad[i].wy
else
if k>=2 then
begin
if (topo[i,k]=true) and (uklad[i].wy=false) then
uklad[k].we:=uklad[i].wy;
end;
end;
end;
end;

procedure clear;
var
i:integer;
j:integer;
begin
for i:=1 to N do
begin
uklad[i].we:=false;
uklad[i].st:=false;
uklad[i].wy:=false;
end;
for i:=1 to N do
for j:=1 to N do
topo[i,j]:=false

end;

procedure show;
var
i: integer;
begin
clrscr;
for i:=1 to N do
write( i,'[',
b2c(uklad[i].we),
b2c(uklad[i].st),
b2c(uklad[i].wy),
'] ');
end;

begin

clear;

topo[1][2]:=true;
topo[2][3]:=true;
topo[2][4]:=true;
topo[2][6]:=true;
topo[3][5]:=true;
topo[4][5]:=true;
topo[5][7]:=true;
topo[6][7]:=true;

uklad[1].we :=true;

show;
repeat
repeat until keypressed;
kc:=readkey;
ki:=ord(kc)-ord('0');
uklad[ki].st := not uklad[ki].st;
simulate;
show;
until kc=' ';
end.

tylko niestety nie dziala opcja pomiedzy 3 i 5 oraz 5 i 7 :( prosze was o pomoc