永发信息网

【急!!】有关一道PASCAL的问题(马鞍数)

答案:1  悬赏:80  手机版
解决时间 2021-06-06 07:13
  • 提问者网友:雾里闻花香
  • 2021-06-06 00:07

program project1;
const
max=10;
var
m,n:integer;
a:array[1..max,1..max] of integer;
b,c,d:array[1..max] of integer;
ro:integer;
ra:integer;
procedure duru;
var
fin:text;
i,j,y:integer;
begin
assign(fin,'horse.in');
reset(fin);
read(fin,m,n);
ro:=maxint;
ra:=-maxint;
for i:=1 to m do
for j:=1 to n do
begin
readln(fin,a[i,j]);
if a[i,j]<ro then begin ro:=a[i,j];b[i]:=a[i,j]; end;
if a[i,j]>ra then begin ra:=a[i,j];c[i]:=a[i,j]; end;

end;
close(fin);

end;

procedure shuchu;
var
fout:text;
i,j:integer;
begin
assign(fout,'horse.out');
rewrite (fout);
begin
for i:=1 to m do
for j:=1 to n do
if (a[i,j]=b[i]) and (a[i,j]=c[i]) then
begin
d[i]:=a[i,j];
writeln(d[i]);
end
else
writeln('no');
end;
close(fout);
end;
begin
duru();
shuchu();
end.

太晚编的,思维有些混乱,请指出怎么错了(注:horse.in有测试数据,ro代表行,ra代表列,m,n分别是测试数据中的代表行列 如

5{行} 5{列}
5 6 7 8 9
4 5 6 7 8
3 4 5 2 1
2 3 4 9 0
1 2 5 4 8
若错的太多,请用过程、函数重写帮我写,思路最好和我一样,谢谢!!

最佳答案
  • 五星知识达人网友:廢物販賣機
  • 2021-06-06 00:53
var a:array[1..10,1..10] of integer;
b,c:array[1..10] of integer;
m,n,min,max,i,j,pan:integer;
begin
pan:=1;
readln(n,m);
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
for i:=1 to n do
begin
min:=a[i,1];
for j:=2 to m do
if a[i,j]<min then min:=a[i,j];
b[i]:=min;
end;
for j:=1 to m do
begin
max:=a[1,j];
for i:=2 to n do
if a[i,j]>max then max:=a[i,j];
c[j]:=max;
end;
for i:=1 to n do
for j:=1 to m do
if (a[i,j]=b[i]) and (a[i,j]=c[j]) then
begin
writeln(i,' ',j,' ',a[i,j]);
pan:=0;
exit;
end;
if pan=1 then writeln('not exit');
end.
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯