Составить проект. вычислить среднее арифметическое отрицательных элементов массива с1, , пологая, что в массиве есть отрицательные значения. ( это нужно сделать в паскале.)
// PascalABC.NET 3.0, сборка 1111 const alpha=['a'..'z']; digits=['0'..'9']; var na,nd,i:integer; s:string; begin na:=0; nd:=0; Write('Введите текст: '); Readln(s); for i:=1 to Length(s) do if s[i] in alpha then Inc(na) else if s[i] in digits then Inc(nd); if na>nd then Writeln('В тексте больше букв') else if na<nd then Writeln('В тексте больше цифр') else Writeln('В тексте букв и цифр поровну') end.
Тестовое решение: Введите текст: the equation 3.546x^2+4.18x-4.1=0 В тексте больше букв
// PascalABC.NET 3.0, сборка 1111 const alpha=['a'..'z']; digits=['0'..'9']; var na,nd,i:integer; s:string; begin na:=0; nd:=0; Write('Введите текст: '); Readln(s); for i:=1 to Length(s) do if s[i] in alpha then Inc(na) else if s[i] in digits then Inc(nd); if na>nd then Writeln('В тексте больше букв') else if na<nd then Writeln('В тексте больше цифр') else Writeln('В тексте букв и цифр поровну') end.
Тестовое решение: Введите текст: the equation 3.546x^2+4.18x-4.1=0 В тексте больше букв
var
c: array[1..30] of integer;
i,n,k:integer;
begin
n:=0;
k:=0;
for i:=1 to 30 do
readln(c[i]);
for i:=1 to 30 do begin
if c[i]<0 then begin
n:=n+1;
k:=k+c[i];
end;
end;
writeln('srednee=', k/n )
end.