ZiegelMan

var_14

May 20th, 2020
385
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program var_14;
  2. var
  3.   mtrx: array[1 ..8, 1..8] of integer;
  4.   i,j: integer;
  5.   max,min:array[1..3] of integer;
  6. begin
  7.   for i:=1 to 8 do begin
  8.     for j:=1 to 8 do begin
  9.       mtrx [i,j]:=random(201)-100;
  10.       write(mtrx [i,j]:4);
  11.       if (i = 1)and(j = 1) then begin
  12.         min[1]:=mtrx [i,j];
  13.         max[1]:=min[1];
  14.       end;
  15.       if mtrx [i,j] > max[1] then begin
  16.         max[1]:=mtrx [i,j];
  17.         max[2]:=i;
  18.         max[3]:=j;
  19.       end;
  20.       if mtrx [i,j] < min[1] then begin
  21.         min[1]:=mtrx [i,j];
  22.         min[2]:=i;
  23.         min[3]:=j;
  24.       end;
  25.     end;
  26.     writeln();
  27.   end;
  28.   writeln();
  29.   writeln(min[1],' <=> ',max[1]);
  30.   writeln();
  31.   mtrx [min[2],min[3]]:=mtrx [min[2],min[3]]+mtrx [max[2],max[3]];
  32.   mtrx [max[2],max[3]]:=mtrx [min[2],min[3]]-mtrx [max[2],max[3]];
  33.   mtrx [min[2],min[3]]:=mtrx [min[2],min[3]]-mtrx [max[2],max[3]];
  34.   for i:=1 to 8 do begin
  35.     for j:=1 to 8 do begin
  36.       if ((i=min[2])and(j=min[3]))or((i=max[2])and(j=max[3])) then
  37.         write(mtrx [i,j]:4,'!')
  38.       else
  39.         write(mtrx [i,j]:4);
  40.     end;
  41.     writeln();
  42.   end;
  43. end.
RAW Paste Data