Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE zad310a;
- FROM InOut IMPORT WriteLn,WriteString,ReadString,WriteInt;
- FROM FIO IMPORT File,Close,Open,Create,RdInt,WrInt,EOF,WrLn;
- FROM Stek IMPORT StekTip,Top,Pop,Push,Empty,MakeNull;
- CONST i1 = "s1i.txt";
- i2 = "s2i.txt";
- VAR str : ARRAY [1..256] OF CHAR;
- s1,s2:StekTip;
- ok:BOOLEAN;
- PROCEDURE Ucitaj(imeF:ARRAY OF CHAR; VAR stek:StekTip; VAR ok:BOOLEAN);
- VAR f:File;
- n:INTEGER;
- BEGIN
- MakeNull(stek);
- f:=Open(imeF);
- EOF:=FALSE;
- WHILE NOT EOF DO
- n:=RdInt(f);
- Push(stek,n,ok);
- END;
- Close(f);
- END Ucitaj;
- PROCEDURE Ispis(stek:StekTip;VAR ok:BOOLEAN);
- VAR n:INTEGER;
- BEGIN
- WHILE NOT Empty(stek) DO
- Top(stek,n,ok);
- Pop(stek,ok);
- WriteInt(n,1);
- WriteLn;
- END;
- END Ispis;
- PROCEDURE UkloniParne(VAR stek:StekTip;VAR ok:BOOLEAN);
- VAR n:INTEGER;
- m:BOOLEAN;
- BEGIN
- m:=TRUE;
- WHILE m AND NOT Empty(stek) DO
- Top(stek,n,ok);
- IF (n MOD 2 = 0) THEN
- Pop(stek,ok);
- ELSE
- m:=FALSE;
- END;
- END;
- END UkloniParne;
- PROCEDURE UkloniSled(VAR stek:StekTip; VAR ok:BOOLEAN);
- VAR x,y:INTEGER;
- m:BOOLEAN;
- BEGIN
- m:=TRUE;
- WHILE m AND NOT Empty(stek) DO
- Top(stek,x,ok);
- Pop(stek,ok);
- Top(stek,y,ok);
- IF (x<y) OR Empty(stek) THEN
- Push(stek,x,ok);
- m:=FALSE;
- END;
- END;
- END UkloniSled;
- PROCEDURE Sacuvaj(imeF:ARRAY OF CHAR; VAR stek:StekTip;VAR ok:BOOLEAN);
- VAR f:File;
- n:INTEGER;
- BEGIN
- f:=Create(imeF);
- WHILE NOT Empty(stek) DO
- Top(stek,n,ok);
- Pop(stek,ok);
- WrInt(f,n,0);
- WrLn(f);
- END;
- Close(f);
- END Sacuvaj;
- BEGIN
- Ucitaj(i1,s1,ok);
- Ucitaj(i2,s2,ok);
- UkloniParne(s1,ok);
- UkloniSled(s2,ok);
- Ispis(s1,ok);
- WriteLn;
- WriteLn;
- Ispis(s2,ok);
- WriteLn;
- WriteString('Unesite ime fajla: '); //int1.txt
- ReadString(str);
- Sacuvaj(str,s1,ok);
- WriteLn;
- WriteString('Unesite ime 2. fajla: '); //int2.txt
- ReadString(str);
- Sacuvaj(str,s2,ok);
- WriteLn;
- END zad310a.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement