Advertisement
ridjis

3. zad prosjek matrice

Dec 5th, 2013
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE provr;
  2. FROM InOut IMPORT WriteLn, WriteString, WriteCard, ReadCard;
  3. FROM RealInOut IMPORT WriteReal;
  4. TYPE matra= ARRAY [1..20], [1..20] OF CARDINAL;
  5. VAR m: matra;
  6.     i,j,n,g,sum: CARDINAL;
  7.     avg: REAL;
  8.     s: ARRAY [1..20] OF CARDINAL;
  9. BEGIN
  10.   WriteString('Unesite dimenziju matrice po vrstama: ');
  11.   ReadCard(n);
  12.   WriteLn;
  13.   WriteString('Unesite dimenziju matrice po kolonama: ');
  14.   ReadCard(g);
  15.   WriteLn;
  16.   WriteString('Unesite matrice: ');
  17.   WriteLn;
  18.   FOR i:=1 TO n DO
  19.     FOR j:=1 TO g DO
  20.       ReadCard(m[i,j]);
  21.     END;
  22.     WriteLn;
  23.   END;
  24.   WriteString('Stampa matrice: ');
  25.   WriteLn;
  26.   FOR i:=1 TO n DO
  27.     FOR j:=1 TO g DO
  28.       WriteCard(m[i,j],5);
  29.     END;
  30.     WriteLn;
  31.   END;
  32.   sum:=0;
  33.   FOR i:=1 TO n DO
  34.     FOR j:=1 TO g DO
  35.       sum:=sum+m[i,j];
  36.     END;
  37.   END;
  38.   WriteString('Suma elemenata matrice je: ');
  39.   WriteCard(sum,0);
  40.   WriteLn;
  41.   avg:=FLOAT(sum) / (FLOAT(n)*FLOAT(g));
  42.   WriteString('Prosjecna vrednost elemenata matrice je: ');
  43.   WriteReal(avg,0);
  44.   WriteLn;
  45. END provr.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement