Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE zad310b;
- FROM InOut IMPORT WriteLn,WriteString,ReadString;
- FROM RealInOut IMPORT WriteReal;
- FROM FIO IMPORT File,Close,Open,Create,RdReal,WrReal,EOF,WrLn;
- FROM RedOpsl IMPORT RedOpslTip,First,PopFirst,AddRear,Empty,MakeNull;
- CONST r1 = "re1.txt";
- r2 = "re2.txt";
- VAR str : ARRAY [1..256] OF CHAR;
- red1,red2:RedOpslTip;
- ok:BOOLEAN;
- suma:REAL;
- PROCEDURE UcitajRed(imeF:ARRAY OF CHAR;VAR red:RedOpslTip; VAR ok:BOOLEAN);
- VAR f:File;
- n:REAL;
- BEGIN
- MakeNull(red);
- f:=Open(imeF);
- EOF:=FALSE;
- WHILE NOT EOF DO
- n:=RdReal(f);
- AddRear(red,n,ok);
- END;
- Close(f);
- END UcitajRed;
- PROCEDURE BezDecimala(VAR red:RedOpslTip; VAR ok:BOOLEAN; VAR suma:REAL);
- VAR n:REAL;
- m:BOOLEAN;
- BEGIN
- m:=TRUE;
- suma:=0.;
- WHILE m AND NOT Empty(red) DO
- First(red,n,ok);
- IF n = FLOAT(TRUNC(n)) THEN
- suma:=suma+n;
- PopFirst(red,ok);
- ELSE
- m:=FALSE;
- END;
- END;
- END BezDecimala;
- PROCEDURE DodajNaKraj(VAR red:RedOpslTip; VAR ok:BOOLEAN; VAR suma:REAL);
- BEGIN
- AddRear(red,suma,ok);
- END DodajNaKraj;
- PROCEDURE Ispis(red:RedOpslTip;VAR ok:BOOLEAN);
- VAR n:REAL;
- BEGIN
- WHILE NOT Empty(red) DO
- First(red,n,ok);
- WriteReal(n,1);
- WriteLn;
- PopFirst(red,ok);
- END;
- END Ispis;
- PROCEDURE Sacuvaj(imeF:ARRAY OF CHAR; VAR red:RedOpslTip;VAR ok:BOOLEAN);
- VAR f:File;
- n:REAL;
- BEGIN
- f:=Create(imeF);
- WHILE NOT Empty(red) DO
- First(red,n,ok);
- PopFirst(red,ok);
- WrReal(f,n,3,1);
- WrLn(f);
- END;
- Close(f);
- END Sacuvaj;
- BEGIN
- UcitajRed(r1,red1,ok);
- UcitajRed(r2,red2,ok);
- BezDecimala(red1,ok,suma);
- Ispis(red1,ok);
- WriteLn;
- DodajNaKraj(red2,ok,suma);
- Ispis(red2,ok);
- WriteLn;
- WriteString('Unesite ime fajla: '); //izlaz1.txt
- ReadString(str);
- Sacuvaj(str,red1,ok);
- WriteString('Unesite ime fajla 2: '); //izlaz2.txt
- ReadString(str);
- Sacuvaj(str,red2,ok);
- END zad310b.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement