Advertisement
ridjis

PolinomiK

Jan 16th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE kolo;
  2. FROM InOut IMPORT WriteString,WriteLn,WriteInt;
  3. FROM PolinomN IMPORT Polinom,Stampaj,Ucitaj,Puta,NadjiStepen;
  4.  
  5. PROCEDURE Parni(p:Polinom; VAR j:INTEGER);
  6. VAR i:INTEGER;
  7. BEGIN
  8.   IF p.st>-1 THEN
  9.     FOR i:=0 TO p.st DO
  10.       IF i MOD 2 = 0 THEN
  11.         IF p.k[i]>0.0 THEN
  12.           INC(j);
  13.     END;
  14.       END;
  15.     END;
  16.   END;
  17.   WriteInt(j,0);
  18. END Parni;
  19.  
  20. PROCEDURE Prethodni(p:Polinom);
  21. VAR i:INTEGER;
  22. BEGIN
  23.   IF p.st>-1 THEN
  24.     FOR i:=0 TO p.st DO
  25.       IF (p.k[i]#0.0) AND (p.k[i]>p.k[i+1]) THEN
  26.         p.k[i]:=0.0;
  27.       END;
  28.     END;
  29.   END;
  30.   NadjiStepen(p);
  31.   Stampaj(p,0);
  32. END Prethodni;
  33.  
  34. VAR p,q,pq,r,w,x,xp:Polinom;
  35.     j:INTEGER;
  36.     ok:BOOLEAN;
  37.  
  38. BEGIN
  39. (*A*)
  40.   WriteString('Unesite polinom p(x): ');
  41.   Ucitaj(p);
  42.   WriteLn;
  43.   (*q(x)*)
  44.   q.st:=5;
  45.   q.k[5]:=3.0;
  46.   q.k[3]:=2.0;
  47.   q.k[0]:=9.0;
  48.   Puta(p,q,pq,ok);
  49.   IF ok THEN
  50.     WriteString('p(x)*q(x)= ');
  51.     Stampaj(pq,0);
  52.   ELSE
  53.     WriteString('Stepen izvan granica!');
  54.   END;
  55.   WriteLn;
  56. (*B*)
  57.   x.st:=5;
  58.   x.k[5]:=8.0;
  59.   x.k[2]:=7.0;
  60.   Puta(x,p,xp,ok);
  61.   Puta(xp,q,r,ok);
  62.   WriteString('r(x) = ');
  63.   Stampaj(r,0);
  64.   WriteLn;
  65. (*C*)
  66.   WriteString('Broj monoma sa parnim stepenom: ');
  67.   Parni(r,j);
  68.   WriteLn;
  69. (*D*)
  70.   WriteString('Monomi kojima je koef veci od predhodnog: ');
  71.   Prethodni(r);
  72.   WriteLn;
  73.  
  74. END kolo.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement