

{
PROGRAMMED BY   : MOHAMMAD ALJADA
DOWNLOADED FROM : WWW.GEOCITIES.COM/MOHJADA
PROGRAM         : Max & Min
}

USES WINCRT;

VAR ARR:ARRAY[1..100,1..100] OF INTEGER;
    MAX,MAXP1,MAXP2,MIN,MINP1,MINP2,I,J,N,M:INTEGER;


BEGIN

     WRITE('INPUT NUMBER OF ROWS   :');
     READLN(N);
     WRITE('INPUT NUMBER OF COLUMS :');
     READLN(M);


     FOR I:=1 TO N DO
         FOR J:=1 TO M DO
         BEGIN
         WRITE('INPUT ITEM [',I,',',J,'] :');
         READLN(ARR[I,J]);
         END;

     MIN:=ARR[1,1];
     MAX:=ARR[1,1];
     MAXP1:=1;
     MAXP2:=1;
     MINP1:=1;
     MINP2:=1;

     FOR I:=1 TO N DO
         FOR J:=1 TO M DO
         BEGIN

              IF ARR[I,J] > MAX THEN
              BEGIN
              MAX:=ARR[I,J];
              MAXP1:=I;
              MAXP2:=J;
              END;

              IF ARR[I,J] < MIN THEN
              BEGIN
              MIN:=ARR[I,J];
              MINP1:=I;
              MINP2:=J;
              END;

     END;


     WRITELN('THE MAXIMUM NUMBER IS : ',MAX);
     WRITELN('ITS POSITION          : [',MAXP1,',',MAXP2,']');
     WRITELN('THE MINIMUM NUMBER IS : ',MIN);
     WRITELN('ITS POSITION          : [',MINP1,',',MINP2,']');
END.

      