👤

Se citește un vector cu n componente reale. Sa cere să se afle suma componentelor negative, produsul elementelor pozitive și numărul elementelor nule​

Răspuns :

float n, v[2000], s=0, p=1, n0=0;

int n;

cin>>n;

for(int i=1; i<=n; i++)

{

cin>>v[i];

if(v[i]==0) n0++;

if(v[i]<0) s=s+v[i];

if(v[i]>0) p=p*v[i];

}

cout<<"Elemente nule: "<<n0<<"\n";

cout<<"Produsul elementelor pozitive: "<<p<<"\n";

cout<<"Suma elementelor negative: "<<s;