Const n = 50; // количество чиселvar k: array [1..n] of integer; i, j, n1, n2, minr, a, b: integer; begin writeln(n, ' ', ': d'); a : = random(1000); b : = random(1000); minr : = 10000; for i : = 1 to n do k[i] : = a + random(b); for i : = 1 to n do for j : = 1 to n do if ((abs(k[i] - k[j])) < minr) and (k[i] < > k[j]) then begin minr : = abs(k[i] - k[j]); n1 : = i; n2 : = j; end; writeln(n1, ' ', n2); end.
const n=5; var a:array[1..n,1..n] of integer; x:array[1..n] of double; i,j,k:byte; begin Randomize; Writeln('*** Исходный массив ***'); for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=Random(51)-25; Write(a[i,j]:4) end; Writeln end; Writeln('*** Массив x ***'); for j:=1 to n do begin x[j]:=0; k:=0; for i:=1 to n do if a[i,j] mod 2=0 then begin x[j]:=x[j]+a[i,j]; Inc(k) end; if k>0 then x[j]:=x[j]/k; Write(x[j]:0:5,' ') end; Writeln end.
const
n=5;
var
a:array[1..n,1..n] of integer;
x:array[1..n] of double;
i,j,k:byte;
begin
Randomize;
Writeln('*** Исходный массив ***');
for i:=1 to n do begin
for j:=1 to n do begin
a[i,j]:=Random(51)-25;
Write(a[i,j]:4)
end;
Writeln
end;
Writeln('*** Массив x ***');
for j:=1 to n do begin
x[j]:=0; k:=0;
for i:=1 to n do
if a[i,j] mod 2=0 then begin
x[j]:=x[j]+a[i,j]; Inc(k)
end;
if k>0 then x[j]:=x[j]/k;
Write(x[j]:0:5,' ')
end;
Writeln
end.
Тестовое решение:
*** Исходный массив ***
-10 18 -8 -15 5
-21 -18 6 -2 9
-7 22 -4 3 14
21 16 -10 -18 -9
17 3 -14 -18 12
*** Массив x ***
-10.00000 9.50000 -6.00000 -12.66667 13.00000