Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE zlf; {radi_sam0_sa_vec_postojecim_fajlom npr. imena.txt mora biti pretodno kreiran}
- FROM FIO IMPORT Open, RdStr, EOF, File, Close;
- FROM InOut IMPORT WriteString, WriteLn, ReadString;
- FROM Storage IMPORT ALLOCATE, DEALLOCATE;
- FROM Str IMPORT Compare;
- TYPE
- STRING = ARRAY [1..20] OF CHAR;
- pok = POINTER TO Slog;
- Slog = RECORD
- kinf : STRING;
- veza : pok
- END;
- VAR
- lista : pok;
- f : File;
- string1, string2, string3 : STRING;
- nalaziseulisti : BOOLEAN;
- PROCEDURE stampajlistu(lista: pok);
- VAR
- temp : pok;
- BEGIN
- temp := lista;
- WHILE temp <> NIL DO
- WriteString(temp^.kinf);
- WriteLn;
- temp := temp^.veza
- END
- END stampajlistu;
- PROCEDURE unistilistu(VAR lista: pok);
- VAR
- temp : pok;
- BEGIN
- temp := lista;
- WHILE temp <> NIL DO
- lista := lista^.veza;
- DISPOSE(temp);
- temp := lista
- END
- END unistilistu;
- PROCEDURE ucitajulistu(VAR lista: pok; str: STRING);
- VAR
- temp : pok;
- BEGIN
- NEW(temp);
- temp^.kinf := str;
- temp^.veza := lista;
- lista := temp
- END ucitajulistu;
- PROCEDURE proverapripadnosti(lista: pok; str: STRING): BOOLEAN;
- VAR
- temp : pok;
- postoji : BOOLEAN;
- BEGIN
- temp := lista;
- postoji := FALSE;
- WHILE (temp <> NIL) AND NOT postoji DO
- IF Compare(temp^.kinf,str) = 0 THEN
- postoji := TRUE
- END;
- temp := temp^.veza;
- END;
- IF temp <> NIL THEN
- DISPOSE(temp);
- END;
- RETURN postoji
- END proverapripadnosti;
- PROCEDURE ucitajnakraj(VAR lista:pok; str: STRING);
- VAR
- tekuci, temp: pok;
- BEGIN
- NEW(temp);
- temp^.kinf := str;
- temp^.veza := NIL;
- IF lista = NIL THEN
- lista:=temp;
- ELSE
- tekuci := lista;
- WHILE tekuci^.veza#NIL DO
- tekuci:=tekuci^.veza;
- END;
- tekuci^.veza := temp;
- END;
- END ucitajnakraj;
- BEGIN
- lista := NIL;
- f := Open('imena.txt'); (*mora biti vec postojeca*)
- EOF := FALSE;
- WHILE NOT EOF DO
- RdStr(f,string1);
- ucitajulistu(lista,string1)
- END;
- Close(f);
- WriteLn;
- WriteString('Unesite ime stringa za proveru: ');
- ReadString(string3);
- string2 := string3;
- nalaziseulisti := proverapripadnosti(lista,string2);
- IF nalaziseulisti THEN
- WriteString('Uneti String se nalazi se u listi!')
- ELSE
- WriteString('Uneti String se ne nalazi u listi');
- ucitajnakraj(lista,string2);
- END;
- WriteLn;
- WriteLn;
- WriteString(' ISPIS LISTE'); WriteLn;
- stampajlistu(lista);
- END zlf.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement