Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE zad39a;
- FROM Info IMPORT InfoTip;
- FROM RedOpsl IMPORT RedOpslTip,First,PopFirst,AddRear,Empty,MakeNull;
- FROM InOut IMPORT WriteString,ReadString;
- FROM FIO IMPORT File,Open,Create,Close,EOF,RdStr,WrStr,WrLn;
- FROM Str IMPORT Length;
- CONST str1 = "str1.txt"; //sadrzaj: neki stringovi
- str2 = "str2.txt"; //sadrzaj: neki stringovi
- VAR string : InfoTip;
- red1,red2,redStr:RedOpslTip;
- ok:BOOLEAN;
- PROCEDURE Ucitaj(imeF:ARRAY OF CHAR; VAR red:RedOpslTip; VAR ok:BOOLEAN);
- VAR f:File;
- str : InfoTip;
- BEGIN
- MakeNull(red);
- f:=Open(imeF);
- EOF:=FALSE;
- WHILE NOT EOF DO
- RdStr(f,str);
- AddRear(red,str,ok);
- END;
- Close(f);
- END Ucitaj;
- PROCEDURE Spaja(VAR r1,r2,r3:RedOpslTip;VAR ok:BOOLEAN);
- VAR str : InfoTip;
- BEGIN
- MakeNull(r3);
- WHILE NOT Empty(r1) OR NOT Empty(r2) DO
- IF NOT Empty(r1) THEN
- First(r1,str,ok);
- AddRear(r3,str,ok);
- PopFirst(r1,ok);
- END;
- IF NOT Empty(r2) THEN
- First(r2,str,ok);
- AddRear(r3,str,ok);
- PopFirst(r2,ok);
- END;
- END;
- END Spaja;
- PROCEDURE Odstranjuje(VAR red:RedOpslTip;VAR ok:BOOLEAN);
- VAR str : InfoTip;
- m:BOOLEAN;
- BEGIN
- m:=TRUE;
- WHILE m AND NOT Empty(red) DO
- First(red,str,ok);
- IF Length(str) > 4 THEN
- PopFirst(red,ok);
- ELSE
- m:=FALSE;
- END;
- END;
- END Odstranjuje;
- PROCEDURE SnimiRed(imeF:ARRAY OF CHAR; VAR red:RedOpslTip;VAR ok:BOOLEAN);
- VAR f:File;
- str : InfoTip;
- BEGIN
- f:=Create(imeF);
- WHILE NOT Empty(red) DO
- First(red,str,ok);
- WrStr(f,str);
- PopFirst(red,ok);
- WrLn(f);
- END;
- Close(f);
- END SnimiRed;
- BEGIN
- Ucitaj(str1,red1,ok);
- Ucitaj(str2,red2,ok);
- Spaja(red1,red2,redStr,ok);
- Odstranjuje(redStr,ok);
- WriteString('Unesite ime fajla: ');
- ReadString(string);
- SnimiRed(string,redStr,ok);
- END zad39a.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement