gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f760213)
raw | patch | inline | side by side (parent: f760213)
author | Doni Pracner <quinnuendo@gmail.com> | |
Thu, 6 Feb 2014 15:44:11 +0000 (16:44 +0100) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Thu, 6 Feb 2014 15:44:11 +0000 (16:44 +0100) |
kodovi/polinomi/m2.mod | [deleted file] | patch | blob | history |
kodovi/polinomi/mnozenje.MOD | [deleted file] | patch | blob | history |
kodovi/polinomi/polinom2.mod | [deleted file] | patch | blob | history |
kodovi/polinomi/polinoml-debug.mod | [deleted file] | patch | blob | history |
diff --git a/kodovi/polinomi/m2.mod b/kodovi/polinomi/m2.mod
--- 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
+++ /dev/null
@@ -1,72 +0,0 @@
-MODULE mnozenje;\r
-FROM PolinomL IMPORT Polinom, Stampaj, Anuliraj,\r
- DisposePolinom, UbaciMonom, Unos, Puta;\r
-FROM InOut IMPORT WriteString, WriteLn;\r
-FROM Storage IMPORT ALLOCATE, DEALLOCATE;\r
-\r
-VAR\r
- p,q,rez,pom : Polinom;\r
-\r
-BEGIN\r
- (* korisnik unosi prvi polinom *)\r
- WriteString("Unesite polinom:");\r
- WriteLn;\r
- (*Unos(p);*)\r
- \r
- NEW(p);\r
- p^.k:=1.;\r
- p^.st:=2;\r
- p^.veza:=NIL;\r
- \r
- WriteString("p: ");\r
- Stampaj(p,0);\r
- WriteLn;\r
- \r
- (* drugi polinom kreiramo mi, \r
- monom po monom *)\r
- Anuliraj(q); (* isto sto i q:=NIL; *)\r
- (* formiramo monom x^5 *)\r
- NEW(pom);\r
- pom^.st:=5;\r
- pom^.k:=1.0;\r
- (* dodajemo ga u polinom *)\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
- (* -3 x^4 *)\r
- NEW(pom);\r
- pom^.st := 4;\r
- pom^.k := -3.0;\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
- (* 4 x *)\r
- NEW(pom);\r
- pom^.st := 1;\r
- pom^.k := 4.0;\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
- (* 7 (x^0) *)\r
- NEW(pom);\r
- pom^.st := 0;\r
- pom^.k := 7.0;\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
- WriteString("q: ");\r
- Stampaj(q,0);\r
- WriteLn;\r
- \r
- Puta(q, q, rez);\r
- (* odstampamo rezultat *)\r
- WriteString("q*q: ");\r
- Stampaj(rez,0);\r
- WriteLn;\r
- \r
- (*Puta(p, p, rez);\r
- WriteString("p*p: ");\r
- Stampaj(rez,0);\r
- WriteLn;\r
- *)\r
- \r
- DisposePolinom(p);\r
- DisposePolinom(q);\r
- DisposePolinom(rez);\r
-END mnozenje.\r
diff --git a/kodovi/polinomi/polinom2.mod b/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
+++ /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