Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE listaGranicnik;
- FROM IO IMPORT WrInt, WrLn, RdInt, WrStr;
- FROM Storage IMPORT ALLOCATE, DEALLOCATE;
- FROM InOut IMPORT ReadInt;
- TYPE
- InfoTip = INTEGER;
- Lista = POINTER TO Element;
- Element = RECORD
- veza : Lista;
- kinfo : InfoTip
- END;
- VAR
- t, s, l : Lista;
- i, k, j : INTEGER;
- PROCEDURE MakeList(VAR s: Lista);
- BEGIN
- NEW(s);
- s^.veza := s;
- END MakeList;
- PROCEDURE Empty(s: Lista): BOOLEAN;
- BEGIN
- RETURN s = s^.veza
- END Empty;
- PROCEDURE Isprazni(VAR s: Lista);
- VAR
- temp : Lista;
- BEGIN
- WHILE s # s^.veza DO
- temp := s^.veza;
- s^.veza := s^.veza^.veza;
- DISPOSE(temp)
- END
- END Isprazni;
- PROCEDURE Ispis(s: INTEGER); FORWARD;
- PROCEDURE Stampaj(s: Lista);
- VAR
- temp : Lista;
- BEGIN
- IF NOT Empty(s) THEN
- WrStr("Ispis liste: "); WrLn();
- temp := s^.veza;
- WHILE temp # s DO
- Ispis(temp^.kinfo);
- temp := temp^.veza
- END
- ELSE
- WrStr("Lista je prazna "); WrLn;
- END
- END Stampaj;
- PROCEDURE Ispis(x: INTEGER);
- BEGIN
- WrInt(x,0);
- WrLn()
- END Ispis;
- PROCEDURE DodajPocetak(VAR s: Lista; x: InfoTip);
- VAR
- novi: Lista;
- BEGIN
- NEW(novi);
- novi^.kinfo := x;
- novi^.veza := s^.veza;
- s^.veza := novi
- END DodajPocetak;
- PROCEDURE Unesi(VAR s: Lista;rb: INTEGER);
- VAR
- br : INTEGER;
- BEGIN
- WrStr("Unesite "); WrInt(rb,0); WrStr(". : ");
- ReadInt(br);
- DodajPocetak(s, br);
- END Unesi;
- BEGIN
- MakeList(t);
- FOR i := 1 TO 3 DO
- Unesi(t,i)
- END;
- Stampaj(t);
- Isprazni(t);
- WrStr("Brisanje liste! ");
- Stampaj(t);
- END listaGranicnik.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement