#include
int main()
{
int a,v,n=0;
printf("input int value a\n");
scanf("%d",&a);
while(1){
v=a%10; printf("%d",v);
if (v%2==0)n++;
a=a/10; if (a==0)break;
}
printf("\neven digi number = %d\n",n);
return 0;
}
如果数很大,例如有200位,可以用字符串来处理,程序如下:
#include
int main()
{
char s[201];
int a,v,n=0,i;
printf("input int value a\n");
scanf("%s",s);
for (i=strlen(s)-1;i>=0;i--){
printf("%c",s[i]);
if ((s[i]-'0')%2==0)n++;
}
printf("\neven digi number = %d\n",n);
return 0;
}