#include <iostream>
using namespace std;
int main(){ int n,ma,nrn,aux,p,u; cout<<"n=";cin>>n; ma=0; nrn=0; while(n!=0) { aux=n; while(aux!=0) { p=aux%10; aux=aux/10; } u=n%10; if(p%2==u%2) { ma=ma+n; nrn++; } cout<<"n=";cin>>n; } cout<<"Media aritmetica="<<ma/nrn<<endl; return 0;}
Vezi ca am pus conditia se citesc numere pana la citirea valorii 0