Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE kol1;
- FROM InOut IMPORT WriteInt,WriteLn,WriteString,ReadCard,WriteCard;
- FROM RealInOut IMPORT ReadReal,WriteReal;
- FROM PolinomL IMPORT Polinom, Anuliraj, Unos, Stampaj, PostaviClan,
- Kopiraj, UbaciMonom, DisposePolinom, PolinomNaN, Saberi, Puta;
- FROM Storage IMPORT ALLOCATE, DEALLOCATE;
- VAR p,q,r,a1,a2,a1a2,pq:Polinom;
- pk:CARDINAL;
- PROCEDURE ParniKoef(p:Polinom):CARDINAL;
- VAR temp:Polinom;
- i:CARDINAL;
- BEGIN
- i:=0;
- IF p#NIL THEN
- temp:=p;
- WHILE (temp#NIL) DO
- IF (TRUNC(ABS(temp^.k)) MOD 2 = 0) THEN
- INC(i);
- END;
- temp:=temp^.veza;
- END;
- END;
- RETURN i;
- END ParniKoef;
- PROCEDURE Razlike (p:Polinom);
- VAR temp:Polinom;
- i:CARDINAL;
- BEGIN
- IF (p # NIL) AND (p^.veza # NIL) THEN
- temp:=p;
- WHILE (temp^.veza # NIL) DO
- i:=temp^.st - temp^.veza^.st;
- WriteCard(i,1);
- temp:=temp^.veza;
- WriteLn;
- END;
- ELSE
- WriteString('Polinom ima manje od 2 monoma.');
- WriteLn;
- END;
- END Razlike;
- BEGIN
- WriteString('Unesite polinom p(x): ');
- Unos(p);
- WriteLn;
- PostaviClan(19.0,3,q);
- PostaviClan(6.0,1,q);
- PostaviClan(9.0,0,q);
- WriteString('p(x)= ');
- Stampaj(p,1);
- WriteLn;
- WriteString('q(x)= ');
- Stampaj(q,1);
- WriteLn;
- WriteString('Zbir polinoma p i q je r(x)= ');
- Saberi(p,q,r);
- Stampaj(r,1);
- WriteLn;
- PostaviClan(2.0,4,a1);
- PostaviClan(3.0,3,a2);
- PostaviClan(8.0,0,a2);
- Puta(a1,a2,a1a2);
- Puta(q,p,pq);
- Saberi(a1a2,pq,r);
- WriteLn;
- WriteString('r(x)= ');
- Stampaj(r,1);
- WriteLn;
- WriteString('U polinomu ima ');
- pk:=ParniKoef(r);
- WriteCard(pk,1);
- WriteString(' parnih koeficijenata.');
- WriteLn;
- WriteString('Razlika stepeni izmedju monoma: ');
- WriteLn;
- Razlike(r);
- WriteLn;
- DisposePolinom(p);
- DisposePolinom(q);
- DisposePolinom(r);
- DisposePolinom(a1);
- DisposePolinom(a2);
- DisposePolinom(a1a2);
- DisposePolinom(pq);
- END kol1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement