109.3..Učitati dvodimenzionalni niz - matricu nxm. Izračunati i ispisati sumu elemenata svih neparnih kolona niza.

Tekstualni algoritam:

Listing programa:

PROGRAM p10913023;
USES
  WinCrt;
VAR
  i,j, n, m, s : INTEGER;
  X : ARRAY [1..15,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;
  FOR i := 1 TO n DO  {izlaz}
    BEGIN
      WRITELN;
      FOR j := 1 TO m DO
        WRITE(X[i,j]:4);
    END;
  WRITELN;
  s := 0;
  FOR i := 1 TO n DO  {suma redova}
    FOR j := 1 TO m DO
      IF j MOD 2 <> 0 THEN
        s := s + X[i,j];
  WRITELN('Suma neparnih kolona niza =', s);
END.

Izvođenje programa:

Index