Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.99 KB | None | 0 0
  1. const nStr = 4; nCol = 3;
  2. type  TStr = array[1..nCol] of integer;
  3.       TMatr = array[1..nStr] of TStr;
  4. var matr:TMatr;
  5.  
  6. procedure FindMax(str:TStr;var max:integer);
  7.     var i:integer;
  8.     begin
  9.         max:=str[1];
  10.         for i:=2 to nCol do
  11.             if str[i] > max then
  12.                 max:=str[i];
  13.     end;
  14.  
  15. procedure ReplacePos (var matr:TMatr);
  16.     var i,j,max:integer;
  17.     begin
  18.     for i:=1 to nStr do
  19.   begin
  20.     FindMax(matr[i],max);
  21.             for j:=1 to nCol do
  22.                 if matr[i,j]>0 then
  23.                     matr[i,j]:=max
  24.     end;
  25.     end;
  26.  
  27. procedure formMatr(var m: TMatr);
  28. var i, j: integer;
  29. begin
  30.   writeln('введите матрицу ',nStr,'x',nCol);
  31.   for i:=1 to nStr do
  32.     for j:=1 to nCol do
  33.       read(m[i,j]);
  34.   readln;
  35. end;
  36.  
  37. procedure printResult(m: TMatr);
  38. var i, j: integer;
  39. begin
  40.   writeln('--- РЕЗУЛЬТАТ ---');
  41.   for i:=1 to nStr do
  42.   begin
  43.     for j:=1 to nCol do
  44.       write(m[i,j]:3);
  45.       writeln;
  46.   end
  47. end;
  48.  
  49. begin
  50.     formMatr(matr);
  51.     ReplacePos(matr);
  52.     printResult(matr);
  53.     readln;
  54. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement