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
var
s: string;
i, count: integer;
begin
writeln('Vvedite stroky: ');
readln(s);
for i := 1 to length(s) - 2 do
if copy(s, i, 3) = 'abc' then
count := count + 1;
writeln('Kol-vo: ', count);
end.
2.
var
s1, s2: string;
i, len1, len2: integer;
begin
writeln('Vvedite stroky 1: ');
readln(s1);
writeln('Vvedite stroky 2: ');
readln(s2);
len1 := length(s1);
len2 := length(s2);
if len1 > len2 then writeln('1 stroka dlinnee')
else if len1 < len2 then writeln('2 stroka dlinnee')
else writeln('dlini strok ravnie')
end.
3.
var
s1, s2, s3: string;
begin
writeln('Vvedite stroky 1: ');
readln(s1);
writeln('Vvedite stroky 2: ');
readln(s2);
s3 := s1[1] + s1[2] + s2[1] + s2[2];
writeln('Novaja stroka: ', s3);
end.