109.3.. Učitati dvodimenzionalni niz - matricu nxm. Izračunati i ispisati aritmetičku sredinu niza.
Opis programa:
Tekstualni algoritam:
Listing programa:
PROGRAM p10916001;
USES
WinCrt;
VAR
i, j, n, m : INTEGER;
s, br, as : REAL;
X : ARRAY [1..15,1..15] OF INTEGER;
BEGIN
s := 0;
br := 0;
WRITE('n m =');
READLN(n,m);
WRITELN('Ulaz niza');
FOR i := 1 TO n DO {ulaz}
FOR j := 1 TO m DO
BEGIN
WRITE('X[',i,',',j,']=');
READLN(X[i,j]);
END;
FOR i := 1 TO n DO {izlaz}
BEGIN
WRITELN;
FOR j := 1 TO m DO
WRITE(X[i,j]:4);
END;
WRITELN;
FOR i := 1 TO n DO {as}
FOR j := 1 TO m DO
BEGIN
s := s + X[i,j];
br := br + 1;
END;
IF br > 0 THEN
as := s/br;
WRITELN('Aritmeticka sredina elemenata je ', as);
END.
Izvođenje programa:
Index
|
|