Informatică, întrebare adresată de andreeea66667666, 8 ani în urmă

Se citesc 3 numere întregi x,y,z. Sa se calculeze suma celor pozitive, produsul celor negative si numărul celor nule.


dumitrufrimu100: De pe pbinfo?sau nu

Răspunsuri la întrebare

Răspuns de daniel0806
0

int x, y, z, s=0, p=1, nr=0;

cin >> x >> y >> z;

if (x>0) s+=x;

else if (x<0) p*=x;

else nr++;

if (y>0) s+=y;

else if (y<0) p*=y;

else nr++;

if (z>0) s+=z;

else if (z<0) p*=z;

else nr++;

cout << s << endl << p << endl << nr;

Alte întrebări interesante