Дан массив действительных чисел, размерность которого N. Подсчитать, сколько в нем отрицательных, положительных и ну левых элементов.
Ответы
Ответ дал:
0
Вот на Pascale тебе
program mas;
uses crt;
var i,pol,otr,nul:integer;
x:array[1..100]of real;
n:integer;
begin
writeln('vvedite n');
readln(n);
otr:=0;
pol:=0;
nul:=0;
for i:=1 to n do begin
readln(x[i]);
if x[i]<0 then otr:=otr+1;
if x[i]>0 then pol:=pol+1;
if x[i]=0 then nul:=nul+1;
end; writeln('polojit',pol);
writeln('otricat',otr);
writeln('nulev',nul);
readln;
end.
program mas;
uses crt;
var i,pol,otr,nul:integer;
x:array[1..100]of real;
n:integer;
begin
writeln('vvedite n');
readln(n);
otr:=0;
pol:=0;
nul:=0;
for i:=1 to n do begin
readln(x[i]);
if x[i]<0 then otr:=otr+1;
if x[i]>0 then pol:=pol+1;
if x[i]=0 then nul:=nul+1;
end; writeln('polojit',pol);
writeln('otricat',otr);
writeln('nulev',nul);
readln;
end.
Вас заинтересует
2 года назад
7 лет назад
9 лет назад
9 лет назад