From 74eec3956c02c387de6afb0839d112544881cd3e Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Thu, 6 Feb 2014 16:44:11 +0100 Subject: [PATCH] obrisani nepotrebni test fajlovi kod polinoma --- kodovi/polinomi/m2.mod | 49 ----- kodovi/polinomi/mnozenje.MOD | 72 ------- kodovi/polinomi/polinom2.mod | 56 ------ kodovi/polinomi/polinoml-debug.mod | 305 ----------------------------- 4 files changed, 482 deletions(-) delete mode 100644 kodovi/polinomi/m2.mod delete mode 100644 kodovi/polinomi/mnozenje.MOD delete mode 100644 kodovi/polinomi/polinom2.mod delete mode 100644 kodovi/polinomi/polinoml-debug.mod diff --git a/kodovi/polinomi/m2.mod b/kodovi/polinomi/m2.mod deleted file mode 100644 index 6735e88..0000000 --- a/kodovi/polinomi/m2.mod +++ /dev/null @@ -1,49 +0,0 @@ -MODULE m2; -FROM PolinomL IMPORT Polinom, Stampaj, Anuliraj, - DisposePolinom, UbaciMonom, Unos, Puta,PolinomNaN; -FROM InOut IMPORT WriteString, WriteLn; -FROM Storage IMPORT ALLOCATE, DEALLOCATE; - -VAR - p,q,rez,pom : Polinom; - -BEGIN - (*sa ova dva ispod radi, bez real overflow*) - NEW(p); - p^.veza:=NIL; - - Anuliraj(q); (* isto sto i q:=NIL; *) - NEW(pom); - pom^.st:=5; - pom^.k:=1.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* -3 x^4 *) - NEW(pom); - pom^.st := 4; - pom^.k := -3.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* 4 x *) - NEW(pom); - pom^.st := 1; - pom^.k := 4.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* 7 (x^0) *) - NEW(pom); - pom^.st := 0; - pom^.k := 7.0; - UbaciMonom(pom,q); - DISPOSE(pom); - WriteString("q: "); - Stampaj(q,0); - WriteLn; - - Puta(q, q, rez); - (* odstampamo rezultat *) - WriteString("q*q: "); - Stampaj(rez,0); - WriteLn; - -END m2. diff --git a/kodovi/polinomi/mnozenje.MOD b/kodovi/polinomi/mnozenje.MOD deleted file mode 100644 index 2072063..0000000 --- a/kodovi/polinomi/mnozenje.MOD +++ /dev/null @@ -1,72 +0,0 @@ -MODULE mnozenje; -FROM PolinomL IMPORT Polinom, Stampaj, Anuliraj, - DisposePolinom, UbaciMonom, Unos, Puta; -FROM InOut IMPORT WriteString, WriteLn; -FROM Storage IMPORT ALLOCATE, DEALLOCATE; - -VAR - p,q,rez,pom : Polinom; - -BEGIN - (* korisnik unosi prvi polinom *) - WriteString("Unesite polinom:"); - WriteLn; - (*Unos(p);*) - - NEW(p); - p^.k:=1.; - p^.st:=2; - p^.veza:=NIL; - - WriteString("p: "); - Stampaj(p,0); - WriteLn; - - (* drugi polinom kreiramo mi, - monom po monom *) - Anuliraj(q); (* isto sto i q:=NIL; *) - (* formiramo monom x^5 *) - NEW(pom); - pom^.st:=5; - pom^.k:=1.0; - (* dodajemo ga u polinom *) - UbaciMonom(pom,q); - DISPOSE(pom); - (* -3 x^4 *) - NEW(pom); - pom^.st := 4; - pom^.k := -3.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* 4 x *) - NEW(pom); - pom^.st := 1; - pom^.k := 4.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* 7 (x^0) *) - NEW(pom); - pom^.st := 0; - pom^.k := 7.0; - UbaciMonom(pom,q); - DISPOSE(pom); - WriteString("q: "); - Stampaj(q,0); - WriteLn; - - Puta(q, q, rez); - (* odstampamo rezultat *) - WriteString("q*q: "); - Stampaj(rez,0); - WriteLn; - - (*Puta(p, p, rez); - WriteString("p*p: "); - Stampaj(rez,0); - WriteLn; - *) - - DisposePolinom(p); - DisposePolinom(q); - DisposePolinom(rez); -END mnozenje. diff --git a/kodovi/polinomi/polinom2.mod b/kodovi/polinomi/polinom2.mod deleted file mode 100644 index ec8db12..0000000 --- a/kodovi/polinomi/polinom2.mod +++ /dev/null @@ -1,56 +0,0 @@ -MODULE polinom2; -FROM PolinomL IMPORT Polinom, Stampaj, Anuliraj, - DisposePolinom, UbaciMonom, Unos, Saberi; -FROM InOut IMPORT WriteString, WriteLn; -FROM Storage IMPORT ALLOCATE, DEALLOCATE; - -VAR - p,q,rez,pom : Polinom; - -BEGIN - Anuliraj(p); - NEW(p); - p^.st := 2; - p^.k := 1.0; - p^.veza := NIL; - Stampaj(p,0); - WriteLn; - - Anuliraj(q); (* ovde isto sto i q:=NIL; *) - (* formiramo monom x^5 *) - NEW(pom); - pom^.st:=5; - pom^.k:=1.0; - (* dodajemo ga u polinom *) - UbaciMonom(pom,q); - DISPOSE(pom); - (* -3 x^4 *) - NEW(pom); - pom^.st := 4; - pom^.k := -3.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* 4 x *) - NEW(pom); - pom^.st := 1; - pom^.k := 4.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* 7 (x^0) *) - NEW(pom); - pom^.st := 0; - pom^.k := 7.0; - UbaciMonom(pom,q); - DISPOSE(pom); - (* saberemo polinome *) - Stampaj(q,0); - WriteLn; - - Saberi(q, q, q); - (* odstampamo rezultat *) - Stampaj(q,4); - WriteLn; - DisposePolinom(p); - DisposePolinom(q); - DisposePolinom(rez); -END polinom2. diff --git a/kodovi/polinomi/polinoml-debug.mod b/kodovi/polinomi/polinoml-debug.mod deleted file mode 100644 index 255c539..0000000 --- a/kodovi/polinomi/polinoml-debug.mod +++ /dev/null @@ -1,305 +0,0 @@ -(*polinomL - debug verzija *) -IMPLEMENTATION MODULE PolinomL; -FROM InOut IMPORT Write, WriteString, WriteLn, - WriteCard, ReadCard, Done; -FROM RealInOut IMPORT WriteReal, ReadReal; -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); -VAR - pomocni: Polinom; -BEGIN - IF p = NIL THEN - kopija := NIL - ELSE - NEW(kopija); - kopija^ := p^; - p := p^.veza; - pomocni := kopija; - WHILE p <> NIL DO - NEW(pomocni^.veza); - pomocni := pomocni^.veza; - pomocni^ := p^; - p := p^.veza - END - END -END Kopiraj; - -PROCEDURE Stampaj(p: Polinom; d: CARDINAL); - - PROCEDURE StampajMonom(m : Polinom); - BEGIN - WITH m^ DO - IF st <> 0 THEN - IF ABS(k) <> 1.0 THEN - WriteReal(ABS(k), d) - END; - Write('x'); - IF st <> 1 THEN - Write('^'); - WriteCard(st, 1) - END - ELSE - WriteReal(ABS(k), d) - END - END - END StampajMonom; - -BEGIN - IF p = NIL THEN - WriteReal(0., d) - ELSE - IF p^.k < 0.0 THEN - WriteString(' - ') - END; - StampajMonom(p); - p := p^.veza; - WHILE p <> NIL DO - IF p^.k > 0.0 THEN - WriteString(' + ') - ELSE - WriteString(' - ') - END; - StampajMonom(p); - p := p^.veza - END - END -END Stampaj; - -PROCEDURE UbaciMonom(mon:Polinom; VAR p: Polinom); -VAR - stari, tekuci, kopija: Polinom; -BEGIN - WriteString("um ( "); - IF mon # NIL THEN - NEW(kopija); - kopija^ := mon^; - tekuci := p; - stari := NIL; - WHILE (tekuci#NIL) AND (tekuci^.st>kopija^.st) DO - stari := tekuci; - tekuci := tekuci^.veza - END; - kopija^.veza := tekuci; - IF tekuci = p THEN - p := kopija - ELSE - stari^.veza := kopija - END; - IF (tekuci#NIL) AND (kopija^.st = tekuci^.st) THEN - kopija^.k := kopija^.k + tekuci^.k; - kopija^.veza := tekuci^.veza; - DISPOSE(tekuci); - IF kopija^.k = 0.0 THEN - IF p = kopija THEN - p := kopija^.veza - ELSE - stari^.veza := kopija^.veza - END; - DISPOSE(kopija) - END - END - END; - WriteString("um ) "); -END UbaciMonom; - -PROCEDURE Unos(VAR p : Polinom); -VAR - i, n: CARDINAL; - novi: Polinom; -BEGIN - Anuliraj(p); - REPEAT - WriteLn; - WriteString('Unesite broj monoma n (n>=0) '); - ReadCard(n); - UNTIL Done; - WriteLn; - FOR i := 1 TO n DO - NEW(novi); - WITH novi^ DO - REPEAT - WriteString('Unesite koeficijent monoma br.'); - WriteCard(i, 1); - WriteString(' (<> 0) '); - ReadReal(k); - WriteLn - UNTIL k <> 0.0; - REPEAT - WriteLn; - WriteString('Unesite eksponent monoma br.'); - WriteCard(i, 1); - WriteString(' (>=0) '); - ReadCard(st); - UNTIL Done; - WriteLn; - END; - UbaciMonom(novi, p); - DISPOSE(novi); - END -END Unos; - -PROCEDURE Saberi(p1, p2: Polinom; VAR zbir: Polinom); -BEGIN - Kopiraj(p1, zbir); - WHILE p2 <> NIL DO - UbaciMonom(p2, zbir); - p2 := p2^.veza - END -END Saberi; - -PROCEDURE SaberiNa(p: Polinom; VAR rez: Polinom); -BEGIN - WHILE p <> NIL DO - UbaciMonom(p,rez); - p := p^.veza; - END; -END SaberiNa; - -PROCEDURE PromeniZnak(VAR p: Polinom); -VAR - t: Polinom; -BEGIN - t := p; - WHILE t <> NIL DO - t^.k := - t^.k; - t := t^.veza - END -END PromeniZnak; - -PROCEDURE Oduzmi(p1,p2: Polinom; VAR razlika: Polinom); -BEGIN - Kopiraj(p2, razlika); - PromeniZnak(razlika); - WHILE p1 <> NIL DO - UbaciMonom(p1, razlika); - p1 := p1^.veza - END -END Oduzmi; - -PROCEDURE MonomPuta(p, mon: Polinom; VAR mp: Polinom); -VAR - tekuci: Polinom; -BEGIN - WriteString("mp [ "); - Anuliraj(mp); - IF (mon <> NIL) AND (p <> NIL) THEN - NEW(mp); - mp^.k := p^.k * mon^.k; - mp^.st := p^.st + mon^.st; - p := p^.veza; - tekuci := mp; - WHILE p <> NIL DO - WriteString("mp w {"); - WriteReal(p^.k,0); - WriteCard(p^.st,5); - WriteString("} "); -WriteLn; - NEW(tekuci^.veza); - tekuci := tekuci^.veza; - tekuci^.k := p^.k * mon^.k; - tekuci^.st := p^.st + mon^.st; - p := p^.veza - END; - tekuci^.veza := NIL - END; - WriteString("mp ] "); -END MonomPuta; - -PROCEDURE Puta(p1, p2: Polinom; VAR pr: Polinom); -VAR - pomocni: Polinom; -BEGIN - WriteString("puta "); -WriteInt(p1,0); - Anuliraj(pr); - IF (p1 <> NIL) AND (p2 <> NIL) THEN - MonomPuta(p1, p2, pr); - p2 := p2^.veza; - WHILE p2 <> NIL DO - MonomPuta(p1, p2, pomocni); - WriteString(" puta posle mp2+ "); - WriteLn; - REPEAT - UbaciMonom(pomocni, pr); - pomocni := pomocni^.veza - UNTIL pomocni = NIL; - p2 := p2^.veza - END - END -END Puta; - -PROCEDURE Kolicnik(p1, p2: Polinom; VAR kol, ost: Polinom; VAR ok: BOOLEAN); - - PROCEDURE Deli(VAR kol, ost: Polinom); - VAR - novi, pomocni: Polinom; - BEGIN - IF ost <> NIL THEN - IF ost^.st >= p2^.st THEN - NEW(novi); - novi^.k := - ost^.k / p2^.k; - novi^.st := ost^.st - p2^.st; - MonomPuta(p2, novi, pomocni); - Saberi(ost, pomocni, ost); - novi^.k := - novi^.k; - UbaciMonom(novi, kol); - DISPOSE(novi); - Deli(kol, ost) - END - END - END Deli; - -BEGIN (* Kolicnik *) - ok := TRUE; - Anuliraj(kol); - IF p2 = NIL THEN - ok := FALSE - ELSE - Kopiraj(p1, ost); - Deli(kol, ost) - END -END Kolicnik; - -PROCEDURE PolinomNaN(p: Polinom; n: CARDINAL; - VAR rez: Polinom); -VAR - i: CARDINAL; -BEGIN - IF n = 0 THEN - NEW(rez); - rez^.k := 1.0; - rez^.st := 0; - rez^.veza := NIL; - ELSIF n = 1 THEN - Kopiraj( p, rez ); - ELSE - rez := p; - FOR i := 2 TO n DO - Puta(rez, p, rez) - END - END; -END PolinomNaN; - -PROCEDURE DisposePolinom(VAR p: Polinom); -VAR - pomocni: Polinom; -BEGIN - pomocni := p; - WHILE pomocni # NIL DO - p := p^.veza; - DISPOSE(pomocni); - pomocni := p - END -END DisposePolinom; - -END PolinomL. \ No newline at end of file -- 2.25.1