Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE Hanojske_kule;
- FROM InOut IMPORT WriteString, WriteLn, WriteCard, ReadCard;
- PROCEDURE HanKul(broj, izv, cilj, pom : CARDINAL);
- BEGIN
- IF broj = 1 THEN
- WriteString('Prebaci disk sa stapa ');
- WriteCard(izv,0);
- WriteString(' na stap ');
- WriteCard(cilj,0);
- WriteString(';');
- WriteLn;
- ELSE
- HanKul(broj-1,izv,pom, cilj);
- HanKul(1,izv,cilj,pom);
- HanKul(broj-1,pom,cilj,izv)
- END;
- END HanKul;
- VAR
- n : CARDINAL;
- BEGIN
- WriteString('Unesite broj diskova: ');
- ReadCard(n);
- WriteLn;
- WriteString(' resenje ');
- WriteLn;
- HanKul(n,1,2,3);
- END Hanojske_kule.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement