Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n = 0, x = 0, sumaPozitive = 0, sumaNegative = 0, nrPozitive = 0, nrNegative = 0, nrZero = 0;
cin >> n;
for( int i = 0; i < n; ++i )
{
cin >> x;
if( x > 0 )
{
sumaPozitive += x;
++nrPozitive;
}
else if( x < 0 )
{
sumaNegative += x;
++nrNegative;
}
else
{
++nrZero;
}
}
cout << sumaPozitive << " " << sumaNegative << " " << nrPozitive << " " << nrNegative << " " << nrZero;
return 0;
}
Explicație: