定义一个包含10个元素的一维数组,从键盘分别给这个一维数组赋值,求出其中的最大值、最小值及它们的下标

2024-10-27 23:10:52
推荐回答(2个)
回答1:

2.program wt(input,output);
var
a:array[1..3,1..5]of longint;
i,j,max,h,l:longint;
begin
for i:=1 to 3 do
for j:=1 to 5 do
read(a[i,j]);
for i:=1 to 3 do
for j:=1 to 5 do
if a[i,j]>max then begin max:=a[i,j];h:=i;l:=j;end;
writeln(max);
writeln('hang:',h,'lie:',l);
end.
3.program wt(input,output);
var
a:array[1..10]of longint;
i,max,min,m,x,t:longint;
begin
min:=maxint;
for i:=1 to 10 do
begin
read(a[i]);
if a[i]if a[i]>max then begin max:=a[i];x:=i;end;
end;
t:=a[m];a[m]:=a[1];a[1]:=t;
t:=a[x];a[x]:=a[10];a[10]:=t;
for i:=1 to 10 do
write(a[i],' ');
end.
4.program wt(input,output);
var
a,b,c:array[1..3,1..4]of longint;
i,j:longint;
begin
for i:=1 to 3 do
for j:=1 to 4 do
read(a[i,j]);
for i:=1 to 3 do
for j:=1 to 4 do
read(b[i,j]);
for i:=1 to 3 do
for j:=1 to 4 do
c[i,j]:=a[i,j]*b[i,j];
for i:=1 to 3 do
begin
for j:=1 to 4 do
write(c[i,j],' ');
writeln;
end;
end.

回答2:

这么多问题,,给个有心人帮你吧..