Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*Radna verzija, treba proveriti zasto ne ubacuje*)
- (*na pocetak lista i doraditi unos*)
- (*Zadatak, ucitati iz fajla u listu imena koja su leksikografski poredjana*)
- (*zatim ucitati odredjeni string i taj string ubaciti u listu bez da se pokvari redosled*)
- MODULE leks;
- FROM InOut IMPORT ReadString, WriteString, WriteLn;
- FROM Storage IMPORT ALLOCATE;
- FROM FIO IMPORT RdStr, EOF, Open, Close, File;
- 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;
- str : STRING;
- f : File;
- PROCEDURE ucitaj(VAR lista: pok; string: STRING);
- VAR
- temp : pok;
- BEGIN
- NEW(temp);
- temp^.kinf := string;
- temp^.veza := lista;
- lista := temp
- END ucitaj;
- PROCEDURE stampaj(lista: pok);
- VAR
- temp : pok;
- BEGIN
- temp := lista;
- WriteString('Stamanje unete liste:');
- WriteLn;
- WHILE temp <> NIL DO
- WriteString(temp^.kinf);
- WriteLn;
- temp := temp^.veza
- END;
- END stampaj;
- PROCEDURE unosporedosledu(VAR lista: pok; unetistring: STRING);
- VAR
- temp, tekuci : pok;
- compare : BOOLEAN;
- BEGIN
- NEW(temp);
- temp^.kinf := unetistring;
- temp^.veza := NIL;
- compare := FALSE;
- IF Compare(unetistring,lista^.kinf) >= 0 THEN
- compare := TRUE;
- WriteString('Error prvog reda!');
- END;
- IF (lista = NIL) OR compare THEN
- temp^.veza := lista;
- lista := temp
- ELSE
- WriteString('Error drugog reda!');
- tekuci := lista;
- IF Compare(tekuci^.veza^.kinf,unetistring) >= 0 THEN
- compare := TRUE
- END;
- WHILE (tekuci^.veza <> NIL) AND compare DO
- compare := FALSE;
- tekuci := tekuci^.veza;
- WriteString('Error treceg reda! ');
- IF Compare(tekuci^.veza^.kinf,unetistring) >= 0 THEN
- compare := TRUE
- END;
- WriteString('Error cetvrtog reda!');
- END;
- WriteString('Greska pri dodeli!');
- temp^.veza := tekuci^.veza;
- tekuci^.veza := temp
- END;
- END unosporedosledu;
- BEGIN
- lista := NIL;
- f := Open('imena.txt');
- WHILE NOT EOF DO
- RdStr(f,str);
- ucitaj(lista,str)
- END;
- Close(f);
- WriteString('Unos Gotov!'); WriteLn;
- stampaj(lista); WriteLn;
- WriteString('unosporedosledu!'); WriteLn;
- WriteString('Unesite string koji zelite da unesete leksikografski u list: ');
- ReadString(str); WriteLn;
- unosporedosledu(lista,str);
- WriteString('Stampanje liste posle leksikografskog unosa!: ');
- WriteLn; WriteLn;
- stampaj(lista);
- END leks.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement