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: 63cfdcb)
raw | patch | inline | side by side (parent: 63cfdcb)
author | Doni Pracner <quinnuendo@gmail.com> | |
Wed, 5 Feb 2014 21:52:28 +0000 (22:52 +0100) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Wed, 5 Feb 2014 21:52:28 +0000 (22:52 +0100) |
kodovi/polinomi/POLINOML.DEF | patch | blob | history | |
kodovi/polinomi/POLINOML.MOD | patch | blob | history | |
kodovi/polinomi/polinom.MOD | patch | blob | history |
index 5b50bc19d235da77f7d02b03e49e2ac8a65e86d1..a88e55b9d937516f93ea9ab76caea25a397f12eb 100644 (file)
(* Modul za rad sa polinomima preko listi\r
- verzija 2012, rev 1 *)\r
+ verzija 2014 *)\r
DEFINITION MODULE PolinomL;\r
TYPE\r
Polinom = POINTER TO Monom;\r
PROCEDURE Stampaj(p: Polinom; d: CARDINAL);\r
PROCEDURE Kopiraj(p: Polinom; \r
VAR kopija: Polinom);\r
+PROCEDURE PostaviClan(k: REAL; st:CARDINAL; \r
+ VAR p:Polinom);\r
PROCEDURE UbaciMonom(mon:Polinom; \r
VAR p: Polinom);\r
PROCEDURE PromeniZnak(VAR p: Polinom);\r
index 405e485774b4a471e50e8144efd00549032398c5..3781d25664f057c190e2699dc176df7856ef8dcc 100644 (file)
(* Modul za rad sa polinomima preko listi\r
- verzija 2012, rev 1 *)\r
+ verzija 2014 *)\r
IMPLEMENTATION MODULE PolinomL;\r
FROM InOut IMPORT Write, WriteString, WriteLn,\r
WriteCard, ReadCard, Done;\r
END\r
END Stampaj;\r
\r
+PROCEDURE PostaviClan(k:REAL; st:CARDINAL;\r
+ VAR p:Polinom);\r
+VAR\r
+ cilj, prethodni : Polinom;\r
+BEGIN\r
+ cilj := p;\r
+ prethodni := NIL;\r
+ WHILE (cilj # NIL) AND (cilj^.st>st) DO\r
+ prethodni := cilj;\r
+ cilj := cilj^.veza;\r
+ END;\r
+ IF (cilj = NIL) THEN\r
+ IF k#0.0 THEN\r
+ NEW(cilj);\r
+ cilj^.k := k;\r
+ cilj^.st := st;\r
+ cilj^.veza := NIL;\r
+ IF (p = NIL) THEN\r
+ p := cilj;\r
+ ELSE\r
+ prethodni^.veza := cilj;\r
+ END;\r
+ END;\r
+ ELSIF cilj^.st=st THEN\r
+ IF k#0.0 THEN\r
+ cilj^.k:=k;\r
+ ELSE\r
+ IF (p=cilj) THEN\r
+ DISPOSE(p);\r
+ ELSE\r
+ prethodni^.veza:= prethodni^.veza^.veza;\r
+ DISPOSE(cilj);\r
+ END;\r
+ END;\r
+ ELSE\r
+ IF k#0.0 THEN\r
+ NEW(cilj);\r
+ cilj^.k := k;\r
+ cilj^.st := st;\r
+ cilj^.veza := prethodni^.veza;\r
+ prethodni^.veza := cilj;\r
+ END;\r
+ END;\r
+END PostaviClan;\r
+\r
PROCEDURE UbaciMonom(mon:Polinom; VAR p: Polinom);\r
VAR\r
stari, tekuci, kopija: Polinom;\r
index 3e46e5421c2f8bb256d92f8c009e1ac06461c6ab..923e897983378be364ff914d233b7bba0b73ea5b 100644 (file)
MODULE polinom;\r
FROM PolinomL IMPORT Polinom, Stampaj, Anuliraj,\r
- DisposePolinom, UbaciMonom, Unos, Saberi;\r
+ DisposePolinom, PostaviClan, Unos, Saberi;\r
FROM InOut IMPORT WriteString, WriteLn;\r
FROM Storage IMPORT ALLOCATE, DEALLOCATE;\r
\r
VAR\r
- p,q,rez,pom : Polinom;\r
+ p,q,rez : Polinom;\r
\r
BEGIN\r
(* korisnik unosi prvi polinom *)\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
+ (* postavimo clan x^5 *)\r
+ PostaviClan(1.0,5,q);\r
(* -3 x^4 *)\r
- NEW(pom);\r
- pom^.st := 4;\r
- pom^.k := -3.0;\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
+ PostaviClan(-3.0,4,q);\r
(* 4 x *)\r
- NEW(pom);\r
- pom^.st := 1;\r
- pom^.k := 4.0;\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
+ PostaviClan(4.0,1,q);\r
(* 7 (x^0) *)\r
- NEW(pom);\r
- pom^.st := 0;\r
- pom^.k := 7.0;\r
- UbaciMonom(pom,q);\r
- DISPOSE(pom);\r
+ PostaviClan(7.0,0,q);\r
(* saberemo polinome *)\r
Saberi(p, q, rez);\r
(* odstampamo rezultat i polinome *)\r