Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE zad311b;
- FROM InOut IMPORT WriteLn,WriteString,ReadString,WriteInt;
- FROM FIO IMPORT File,Close,Open,Create,RdCard,WrCard,EOF,WrLn;
- FROM Stek IMPORT StekTip,Top,Pop,Push,Empty,MakeNull;
- CONST br2 = "br2.txt";
- VAR str : ARRAY [1..256] OF CHAR;
- s1,s2:StekTip;
- ok:BOOLEAN;
- PROCEDURE Ucitaj(imeF:ARRAY OF CHAR; VAR s1,s2:StekTip; VAR ok:BOOLEAN);
- VAR f:File;
- m:CARDINAL;
- BEGIN
- MakeNull(s1);
- MakeNull(s2);
- EOF:=FALSE;
- f:=Open(imeF);
- WHILE NOT EOF DO
- m:=RdCard(f);
- Push(s1,m,ok);
- m:=RdCard(f);
- Push(s2,m,ok);
- END;
- Close(f);
- END Ucitaj;
- PROCEDURE Ispis(stek:StekTip;VAR ok:BOOLEAN);
- VAR n:CARDINAL;
- BEGIN
- WHILE NOT Empty(stek) DO
- Top(stek,n,ok);
- Pop(stek,ok);
- WriteInt(n,1);
- WriteLn;
- END;
- END Ispis;
- PROCEDURE Deli4(VAR stek:StekTip; VAR ok:BOOLEAN);
- VAR n:CARDINAL;
- m:BOOLEAN;
- BEGIN
- m:=TRUE;
- WHILE m AND NOT Empty(stek) DO
- Top(stek,n,ok);
- IF (n MOD 4 = 0) THEN
- Pop(stek,ok);
- ELSE
- m:=FALSE;
- END;
- END;
- END Deli4;
- PROCEDURE UkloniAko(VAR stek:StekTip;VAR ok:BOOLEAN);
- PROCEDURE Zbir(n:CARDINAL):CARDINAL;
- VAR temp,suma:CARDINAL;
- BEGIN
- suma:=0;
- REPEAT
- temp:=n MOD 10;
- suma:=temp + suma;
- n:= n DIV 10;
- UNTIL n=0;
- RETURN suma;
- END Zbir;
- VAR x,y:CARDINAL;
- m:BOOLEAN;
- BEGIN
- m:=TRUE;
- WHILE m AND NOT Empty(stek) DO
- Top(stek,x,ok);
- Pop(stek,ok);
- Top(stek,y,ok);
- IF (Zbir(x) < y) OR Empty(stek) THEN
- Push(stek,x,ok);
- m:=FALSE;
- END;
- END;
- END UkloniAko;
- PROCEDURE Snimi(imeF:ARRAY OF CHAR; VAR stek:StekTip; VAR ok:BOOLEAN);
- VAR f:File;
- n:CARDINAL;
- BEGIN
- EOF:=FALSE;
- f:=Create(imeF);
- WHILE NOT Empty(stek) DO
- Top(stek,n,ok);
- Pop(stek,ok);
- WrCard(f,n,0);
- WrLn(f);
- END;
- Close(f);
- END Snimi;
- BEGIN
- Ucitaj(br2,s1,s2,ok);
- WriteString('Uklanja brojeve iz prvog steka, ako su deljivi sa 4: ');
- WriteLn;
- Deli4(s1,ok);
- Ispis(s1,ok);
- WriteLn;
- WriteString('Uklanja brojeve iz drugog steka, ako je zbir cif > sledbenika: ');
- WriteLn;
- UkloniAko(s2,ok);
- Ispis(s2,ok);
- WriteLn;
- WriteString('Unesite ime 1. fajla: ');
- ReadString(str);
- Snimi(str,s1,ok);
- WriteString('Unesite ime 2. fajla: ');
- ReadString(str);
- Snimi(str,s2,ok);
- END zad311b.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement