ridjis

Zadatak 4_1 aritmeticka niza

Nov 8th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE zad41;
  2. FROM InOut IMPORT WriteLn, WriteString, WriteInt, ReadInt, WriteCard,ReadCard;
  3. FROM RealInOut IMPORT WriteReal, ReadReal;
  4. CONST
  5.     max=100;
  6. TYPE
  7.     Niz = ARRAY [1..max] OF INTEGER;
  8. VAR
  9.     n, i: CARDINAL;
  10.     sum,as: REAL;
  11.     niz: Niz;
  12. BEGIN
  13.     WriteString('unesite duzinu niza: ');
  14.     ReadCard(n);
  15.     FOR i:=1 TO n DO
  16.         WriteString('niz[');
  17.         WriteCard(i,1);
  18.         WriteString('] = ');
  19.         ReadInt(niz[i]);
  20.     END;
  21.     WriteString('Niz izgleda ovako: ');
  22.     WriteLn;
  23.     FOR i:=1 TO n DO
  24.         WriteString('niz[');
  25.         WriteCard(i,1);
  26.         WriteString('] = ');
  27.         WriteInt(niz[i],0);
  28.         WriteLn;
  29.     END;
  30.     sum:=0.;
  31.     FOR i:=1 TO n DO
  32.         sum:=sum+FLOAT(niz[i]);
  33.     END;
  34.     WriteString('Arhimeticka sredina sume je: ');  
  35.     as:=sum / FLOAT(n);
  36.     WriteReal(as,0);
  37.  
  38. END zad41.
Add Comment
Please, Sign In to add comment