Ligaevruslan
?>

Вычислить среднее арифметическое отрицательных элементов вектора q(21) p.s.через программу паскаль

Информатика

Ответы

eliteclassic308
Const n=21;
var q:array[1..n] of integer;
i,s,k:integer;
begin
Randomize;
for i:=1 to n do
 begin
 q[i]:=random(51)-10;
 write(q[i]:4);
 end;
writeln;
k:=0; s:=0;
for i:=1 to n do
 if q[i]<0 then begin s:=s+q[i]; k:=k+1; end;
writeln('Среднее арифметическое отрицательных элементов = ',s/k);
end.

Пример:
  16  -1  -7   5  13  11  -2 -10  36  19   3  34  23  29  12  28   9  39  33  16  -6
Среднее арифметическое отрицательных элементов = -5.2
akbmaslafarkop3175
Var
  dc:set of char;
  s1,s2:string;
  i:integer;
begin
  dc:=['A'..'D','a'..'d'];
  s1:='То avoid the impression of the tail wagging the dog, '+
    'the president cannot be seen bending to the wishes of a minority.';
  s2:='';
  for i:=1 to length(s1) do
    if not(s1[i] in dc) then s2:=s2+s1[i];
  Writeln('Исходная строка: ',s1);
  s1:=s2;
  Writeln('Результирующая строка: ',s1)
end.

Тестовое решение:
Исходная строка: То avoid the impression of the tail wagging the dog, the president cannot be seen bending to the wishes of a minority.
Результирующая строка: То voi the impression of the til wgging the og, the presient nnot e seen ening to the wishes of  minority.
many858
Для перевода необходимо умножить разряд числа на соответствующую ему степень разряда.
1011101100010101010111100101010 = 2^30*1 + 2^29*0 + 2^28*1 + 2^27*1 + 2^26*1 + 2^25*0 + 2^24*1 + 2^23*1 + 2^22*0 + 2^21*0 + 2^20*0 + 2^19*1 + 2^18*0 + 2^17*1 + 2^16*0 + 2^15*1 + 2^14*0 + 2^13*1 + 2^12*0 + 2^11*1 + 2^10*1 + 2^9*1 + 2^8*1 + 2^7*0 + 2^6*0 + 2^5*1 + 2^4*0 + 2^3*1 + 2^2*0 + 2^1*1 + 2^0*0 =
1073741824 + 0 + 268435456 + 134217728 + 67108864 + 0 + 16777216 + 8388608 + 0 + 0 + 0 + 524288 + 0 + 131072 + 0 + 32768 + 0 + 8192 + 0 + 2048 + 1024 + 512 + 256 + 0 + 0 + 32 + 0 + 8 + 0 + 2 + 0 = 1569369898

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Вычислить среднее арифметическое отрицательных элементов вектора q(21) p.s.через программу паскаль
Ваше имя (никнейм)*
Email*
Комментарий*