Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE nadjiPut(VAR l:lavirint; VAR maxr:resenje):BOOLEAN;
- PROCEDURE put (x,y:CARDINAL; VAR pos: posete; VAR r:resenje);
- BEGIN
- IF (x<1) OR (x>l.v) OR (y<1) OR (y>l.s) THEN
- RETURN;
- END;
- IF (pos[x,y]) THEN
- RETURN;
- END;
- IF (l.mat[x,y] = zid) THEN
- RETURN;
- END;
- IF (l.mat[x,y] = cilj) THEN
- dodaj(r,x,y);
- IF (r.vrednost > maxr.vrednost) THEN
- maxr := r;
- END;
- izbaciKraj(r);
- ELSE
- pos[x,y] := TRUE;
- dodajv(r,x,y,l.mat[x,y]);
- put(x+1,y, pos,r);
- put(x,y+1, pos,r);
- put(x-1,y, pos,r);
- put(x,y-1, pos,r);
- pos[x,y] := FALSE;
- izbaciKrajv(r, l.mat[x,y]);
- END;
- RETURN;
- END put;
- VAR pos :posete;
- r :resenje;
- BEGIN
- InitFalse(pos,l.v,l.s);
- r.n := 0;
- r.vrednost := 0;
- maxr.vrednost := -1;
- put(1,1,pos,r);
- RETURN maxr.vrednost#-1;
- END nadjiPut;
- PROCEDURE nadjiPutNajkraci(VAR l:lavirint; VAR min:resenje):BOOLEAN;
- PROCEDURE put (x,y:CARDINAL; VAR pos: posete; VAR r:resenje);
- BEGIN
- IF (x<1) OR (x>l.v) OR (y<1) OR (y>l.s) THEN
- RETURN;
- END;
- IF (pos[x,y]) THEN
- RETURN;
- END;
- IF (l.mat[x,y] = zid) THEN
- RETURN;
- END;
- IF (l.mat[x,y] = cilj) THEN
- dodaj(r,x,y);
- IF (r.n < min.n) THEN
- min := r;
- END;
- izbaciKraj(r);
- ELSE
- pos[x,y] := TRUE;
- dodaj(r,x,y);
- put(x+1,y, pos,r);
- put(x,y+1, pos,r);
- put(x-1,y, pos,r);
- put(x,y-1, pos,r);
- pos[x,y] := FALSE;
- izbaciKraj(r);
- END;
- RETURN;
- END put;
- VAR pos :posete;
- r :resenje;
- BEGIN
- InitFalse(pos,l.v,l.s);
- r.n := 0;
- min.n := maxPut+1;
- put(1,1,pos,r);
- RETURN min.n#maxPut+1;
- END nadjiPutNajkraci;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement