From: Doni Pracner Date: Mon, 18 Feb 2013 18:58:36 +0000 (+0100) Subject: polinomL - novija verzija X-Git-Tag: v13a~9 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=ea8cbcbb00e39119afb8edb492516ef1e23c9df5;p=spa1skripta-public.git polinomL - novija verzija --- diff --git a/skripta-spa1.tex b/skripta-spa1.tex index f8923ee..a3a387f 100644 --- a/skripta-spa1.tex +++ b/skripta-spa1.tex @@ -1584,6 +1584,8 @@ END PolinomL. \paragraph{PolinomL.MOD} \ \begin{codeblock} +(* Modul za rad sa polinomima preko listi + verzija 2012, rev 1 *) IMPLEMENTATION MODULE PolinomL; FROM InOut IMPORT Write, WriteString, WriteLn, WriteCard, ReadCard, Done; @@ -1592,13 +1594,10 @@ FROM Storage IMPORT ALLOCATE, DEALLOCATE; PROCEDURE Anuliraj(VAR p: Polinom); BEGIN - IF p # NIL THEN - DisposePolinom(p); - END; + p := NIL; END Anuliraj; -PROCEDURE Kopiraj(p: Polinom; - VAR kopija: Polinom); +PROCEDURE Kopiraj(p: Polinom; VAR kopija: Polinom); VAR pomocni: Polinom; BEGIN @@ -1659,8 +1658,7 @@ BEGIN END END Stampaj; -PROCEDURE UbaciMonom(mon :Polinom; - VAR p: Polinom); +PROCEDURE UbaciMonom(mon:Polinom; VAR p: Polinom); VAR stari, tekuci, kopija: Polinom; BEGIN @@ -1679,8 +1677,7 @@ BEGIN ELSE stari^.veza := kopija END; - IF (tekuci#NIL) AND - (kopija^.st = tekuci^.st) THEN + IF (tekuci#NIL) AND (kopija^.st = tekuci^.st) THEN kopija^.k := kopija^.k + tekuci^.k; kopija^.veza := tekuci^.veza; DISPOSE(tekuci); @@ -1712,17 +1709,17 @@ BEGIN NEW(novi); WITH novi^ DO REPEAT - WriteString('koeficijent monoma br.'); + WriteString('Unesite koeficijent monoma br.'); WriteCard(i, 1); - WriteString(' (<> 0):'); + WriteString(' (<> 0) '); ReadReal(k); WriteLn UNTIL k <> 0.0; REPEAT WriteLn; - WriteString('eksponent monoma br.'); + WriteString('Unesite eksponent monoma br.'); WriteCard(i, 1); - WriteString(' (>= 0): '); + WriteString(' (>=0) '); ReadCard(st); UNTIL Done; WriteLn; @@ -1732,8 +1729,7 @@ BEGIN END END Unos; -PROCEDURE Saberi(p1, p2: Polinom; - VAR zbir: Polinom); +PROCEDURE Saberi(p1, p2: Polinom; VAR zbir: Polinom); BEGIN Kopiraj(p1, zbir); WHILE p2 <> NIL DO @@ -1742,8 +1738,7 @@ BEGIN END END Saberi; -PROCEDURE SaberiNa(p: Polinom; - VAR rez: Polinom); +PROCEDURE SaberiNa(p: Polinom; VAR rez: Polinom); BEGIN WHILE p <> NIL DO UbaciMonom(p,rez); @@ -1762,8 +1757,7 @@ BEGIN END END PromeniZnak; -PROCEDURE Oduzmi(p1,p2: Polinom; - VAR razlika: Polinom); +PROCEDURE Oduzmi(p1,p2: Polinom; VAR razlika: Polinom); BEGIN Kopiraj(p2, razlika); PromeniZnak(razlika); @@ -1773,8 +1767,7 @@ BEGIN END END Oduzmi; -PROCEDURE MonomPuta(p, mon: Polinom; - VAR mp: Polinom); +PROCEDURE MonomPuta(p, mon: Polinom; VAR mp: Polinom); VAR tekuci: Polinom; BEGIN @@ -1815,9 +1808,7 @@ BEGIN END END Puta; -PROCEDURE Kolicnik(p1, p2: Polinom; - VAR kol, ost: Polinom; - VAR ok: BOOLEAN); +PROCEDURE Kolicnik(p1, p2: Polinom; VAR kol, ost: Polinom; VAR ok: BOOLEAN); PROCEDURE Deli(VAR kol, ost: Polinom); VAR @@ -1860,7 +1851,7 @@ BEGIN rez^.st := 0; rez^.veza := NIL; ELSIF n = 1 THEN - Kopiraj( rez, p ); + Kopiraj( p, rez ); ELSE rez := p; FOR i := 2 TO n DO