// PascalABC.Net 3.0, версия 1066 const mm=50; nn=50; var n,m,i,j,k1,k2,p:integer; s1,s2,s3:longint; a:array[1..mm,1..nn] of integer; begin Write('Число строк и столбцов массива: '); Read(m,n); Write('Значение p: '); Read(p); Writeln('*** Сгенерированный массив ***'); Randomize; s1:=0; s2:=0; s3:=0; k1:=0; k2:=0; for i:=1 to m do begin for j:=1 to n do begin a[i,j]:=Random(101)-50; Write(a[i,j]:4); if a[i,j]>30 then s1:=s1+a[i,j]; if Odd(a[i,j]) then Inc(k1) else begin s2:=s2+a[i,j]; Inc(k2) end; if i+j=p then s3:=s3+a[i,j] end; Writeln end; Writeln('Сумма элементов массива, больших 30: ',s1); Writeln('Количество нечетных элементов массива: ',k1); Writeln('Среднее арифметическое четных элементов массива: ',s2/k2); Writeln('Сумма элементов массива c суммой индексов ',p,': ',s3) end.
var
a, b, x, s, p: integer;
begin
writeln(' Ввести х');
readln(x);
s := 0;
x := Abs(x); { защита от ввода отрицательных }
while x > 0 do
begin
s := s + x mod 10;
x := x div 10
end;
writeln(' Сумма цифр=', s);
end.