Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,e,nrpare=0,nrimpare=0;
float sumapare=0,sumaimpare=0;
cin>>a>>b>>c>>d>>e;
if(a%2==0)
{
nrpare++;
sumapare=sumapare+a;
} else {
nrimpare++;
sumaimpare=sumaimpare+a;
}
if(b%2==0)
{
nrpare++;
sumapare=sumapare+b;
} else {
nrimpare++;
sumaimpare=sumaimpare+b;
}
if(c%2==0)
{
nrpare++;
sumapare=sumapare+c;
} else {
nrimpare++;
sumaimpare=sumaimpare+c;
}
if(d%2==0)
{
nrpare++;
sumapare=sumapare+d;
} else {
nrimpare++;
sumaimpare=sumaimpare+d;
}
if(e%2==0)
{
nrpare++;
sumapare=sumapare+e;
} else {
nrimpare++;
sumaimpare=sumaimpare+e;
}
if(nrpare==0 || nrimpare==0)
cout<<"Nu exista";
else {
cout<<"media nr pare: "<<sumapare/nrpare<<endl;
cout<<"media nr impare: "<<sumaimpare/nrimpare;
}
return 0;
}
Explicație: