Răspuns:
#include <iostream>
using namespace std;
int main(){
int n,p=1,pare=0,impare=0,s1=0,s2=0;
cin>>n;
while(n){
p*=n%10;
if((n%10)%2==0){
pare++;
s1+=n%10;
}else{
impare++;
s2+=n%10;
}
n/=10;
}
float medie_pare = (float)s1/pare;
float medie_impare = (float)s2/impare;
cout<<"Produs: "<<p<<endl;
cout<<"Medie cif pare: "<<medie_pare<<endl;
cout<<"Medie cif impare: "<<medie_impare<<endl;
return 0;
}
Explicație:
cand ai s+n%10 e la fel ca s2=s2+n%10 si tot asa