109.3..
Učitati dvodimenzionalni niz - matricu nxm. Izračunati i ispisati aritmetičku sredinu elemenata pete kolone niza X[n,m]
Tekstualni algoritam:
Listing programa:
PROGRAM p10916013;
USES
WinCrt;
VAR
i, j, n, m, S, Br : INTEGER;
As:REAL;
X : ARRAY [1..15,1..15] OF INTEGER;
Sred : ARRAY [1..15] OF INTEGER;
Skol : ARRAY [1..15] OF INTEGER;
BEGIN
WRITE('n m ='); {dimenzije matrice}
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;
S := 0;
Br := 0;
FOR j:= 1 TO m DO
IF j=5 THEN
BEGIN
FOR i:= 1 TO n DO
BEGIN
S := S + X[i,j] ;
Br := Br + 1 ;
END;
WRITELN('As pete kolone je ',s/br);
END;
END.
Izvođenje programa:
Index
|
|