Program abc; Const n=3; m=3; Var a:array[1..n,1..m] of integer; b,y,i,j,sum:integer; srd:real; Begin Writeln('Введите числа массива: '); For i:=1 to n do For j:=1 to m do Begin Write('a[',i,',',j,']= '); Readln(a[i,j]); if a[i,j]>0 then begin sum:=sum+a[i,j]; inc(b); end else If a[i,j]<0 then Inc(y); End; If sum>0 then begin srd:=sum/b; Writeln('Среднее =',srd); end else Writeln('Нет положительных членов массива'); If y>0 then begin Writeln('Количество отрицательных элементов =',y); end else Writeln('Нет отрицательных членов массива'); End.
// PascalABC.NET 3.1, сборка 1250 от 28.05.2016 begin var a:array[1..3] of string; var l:array[1..3] of integer; for var i:=1 to 3 do begin Write('Город ',i,': '); Readln(a[i]); l[i]:=Length(a[i]) end; var imin:=1; var imax:=1; for var i:=2 to 3 do begin if l[i]<l[imin] then imin:=i; if l[i]>l[imax] then imax:=i end; Writeln('Самое длинное название- ',a[imax]); Writeln('Самое короткое название- ',a[imin]) end.
Тестовое решение Город 1: Москва Город 2: Минск Город 3: Киев Самое длинное название- Москва Самое короткое название- Киев
Const
n=3;
m=3;
Var a:array[1..n,1..m] of integer;
b,y,i,j,sum:integer;
srd:real;
Begin
Writeln('Введите числа массива: ');
For i:=1 to n do
For j:=1 to m do
Begin
Write('a[',i,',',j,']= ');
Readln(a[i,j]);
if a[i,j]>0 then
begin
sum:=sum+a[i,j];
inc(b);
end
else
If a[i,j]<0 then
Inc(y);
End;
If sum>0 then
begin
srd:=sum/b;
Writeln('Среднее =',srd);
end
else
Writeln('Нет положительных членов массива');
If y>0 then
begin
Writeln('Количество отрицательных элементов =',y);
end
else
Writeln('Нет отрицательных членов массива');
End.