ulvis.paste.net

Paste Search Dynamic
Recent pastes
[MatLab] lab10
  1. %algorytmik w głąb
  2.           %1 2 3 4 5 6
  3. macierz = [0 1 0 0 1 0;
  4.            1 0 1 1 0 0;
  5.            0 1 0 0 0 0;
  6.            0 1 0 0 0 0;
  7.            1 0 0 0 0 1;
  8.            0 0 0 0 1 0;]
  9.        
  10. open = [1];
  11. closed = [];
  12. i = 0;
  13. jedynki = [1 1 1 1 1 1];
  14. while not(isempty(open)),
  15.      if and(i > 0, i < 7)
  16.          jedynki(i) = [0];
  17.      end
  18.      i = i + 1;
  19.      open = [open, find(macierz(open(1), :).*jedynki)]
  20.      closed = [closed, open(1)]
  21.      open(1) = []
  22. end
Parsed in 0.002 seconds