var ma: array of array of integer; n, m, i, j, max, maxi, maxj: integer; f: text; s, st: string;
begin randomize; readln(n); readln(m); max := -1; setlength(ma, n); for i := 0 to n - 1 do setlength(ma[i], m); writeln('Matrix:'); for i := 0 to n - 1 do begin writeln; for j := 0 to m - 1 do begin ma[i, j] := random(101); write(ma[i, j]:4); if max < ma[i, j] then begin max := ma[i, j]; maxi := i; maxj := j; end; end; end; assign(f, 'text.txt'); rewrite(f); for i := 0 to m - 1 do write(f, ma[maxi, i]:4); writeln(f, ' '); for i := 0 to n - 1 do write(f, ma[i, maxj]:4); close(f); writeln; writeln('File:'); assign(f, 'text.txt'); reset(f); while not Eof(f) do begin; readln(f, st); s := s + st + chr(10) + chr(13); end; close(f); write(s); end.
var
ma: array of array of integer;
n, m, i, j, max, maxi, maxj: integer;
f: text;
s, st: string;
begin
randomize;
readln(n);
readln(m);
max := -1;
setlength(ma, n);
for i := 0 to n - 1 do
setlength(ma[i], m);
writeln('Matrix:');
for i := 0 to n - 1 do
begin
writeln;
for j := 0 to m - 1 do
begin
ma[i, j] := random(101);
write(ma[i, j]:4);
if max < ma[i, j] then
begin
max := ma[i, j];
maxi := i;
maxj := j;
end;
end;
end;
assign(f, 'text.txt');
rewrite(f);
for i := 0 to m - 1 do
write(f, ma[maxi, i]:4);
writeln(f, ' ');
for i := 0 to n - 1 do
write(f, ma[i, maxj]:4);
close(f);
writeln;
writeln('File:');
assign(f, 'text.txt');
reset(f);
while not Eof(f) do
begin;
readln(f, st);
s := s + st + chr(10) + chr(13);
end;
close(f);
write(s);
end.
Пример ввода:
3
4
Пример вывода:
Matrix:
30 29 3 61
64 4 99 36
45 9 85 19
File:
64 4 99 36
3 99 85