109.3.. Učitati dvodimenzionalni niz - matricu nxm. Odredi indeks najmanjeg elementa matrice.

Opis programa:

Tekstualni algoritam:

Listing programa:

PROGRAM p10917026;
USES
  WinCrt;
VAR
  i,j,n,m,min,a,b : INTEGER;
  X : ARRAY [1..15,1..15] OF INTEGER;
BEGIN
  WRITE('n m =');    {dimenzije matrice}
  READLN(n,m);
  WRITELN('Unijeti clanove niza');
  FOR i := 1 TO n DO  
    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;
  min:=X[1,1];
  a:=1;
  b:=1;
  FOR i := 1 TO n DO  
    BEGIN
    FOR j:=1 TO m DO
    IF X[i,j] < min THEN
     BEGIN
      min := X[i,j];
      a := i;
      b := j;
     END;
    END; 
 WRITELN('Najmanji element matrice i njegovi indeski X[', a, ',', b, ']= ', min);
END.

Izvođenje programa:

Index