rubik-nerubik
28.12.2007, 20:31
Последний вопрос по паскалю:
Есть задача:
program db2;
uses crt;
var a,b,i,k,max1,max2:integer;
mas:array[1..100,1..100] of integer;
begin
clrscr;
assign(input,'input2.txt');
reset(input);
assign(output,'output2.txt');
rewrite(output);
readln(i);
readln(k);
for a:=1 to i do
for b:=1 to k do
read(mas[a,b]);
max1:=mas[1,1];
max2:=mas[i,1];
for a:=1 to i do begin
if mas[a,a]>max1 then max1:=mas[a,a];
if mas[a,k-a+1]>max2 then max2:=mas[a,k-a+1];
end;
if max1<max2 then max1:=max2;
mas[(i div 2)+1,(i div 2)+1]:=max1;
for a:=1 to i do begin
writeln;
for b:=1 to k do
writeln(mas[a,b],' ');
end;
end.
и в input.txt такое:
3 3
1 2 3
4 5 6
7 8 9
и выводит он такое:
4
5
6
Вопрос: Как сделать так, чтобы выводил по условию:
Дана действительная квадратная матрица.... Найти наибольший элемент среди стоящих на главной и побочной диагоналях и поменять его местами с элементами, стоящими на пересечении этих диагоналей.
Есть задача:
program db2;
uses crt;
var a,b,i,k,max1,max2:integer;
mas:array[1..100,1..100] of integer;
begin
clrscr;
assign(input,'input2.txt');
reset(input);
assign(output,'output2.txt');
rewrite(output);
readln(i);
readln(k);
for a:=1 to i do
for b:=1 to k do
read(mas[a,b]);
max1:=mas[1,1];
max2:=mas[i,1];
for a:=1 to i do begin
if mas[a,a]>max1 then max1:=mas[a,a];
if mas[a,k-a+1]>max2 then max2:=mas[a,k-a+1];
end;
if max1<max2 then max1:=max2;
mas[(i div 2)+1,(i div 2)+1]:=max1;
for a:=1 to i do begin
writeln;
for b:=1 to k do
writeln(mas[a,b],' ');
end;
end.
и в input.txt такое:
3 3
1 2 3
4 5 6
7 8 9
и выводит он такое:
4
5
6
Вопрос: Как сделать так, чтобы выводил по условию:
Дана действительная квадратная матрица.... Найти наибольший элемент среди стоящих на главной и побочной диагоналях и поменять его местами с элементами, стоящими на пересечении этих диагоналей.