对输入一个数,计算各个位上是偶数的数之和

#include<stdio.h>

int main()
{
    int i=0,count=0;
    char a[100];
    scanf("%s",a);

    while(a[i]!='\0')
    {
        if((a[i]-'0')%2==0)  count+=(a[i]-'0');
        i++;
    }
    printf("%d",count);
}

posted @ 2016-12-23 15:12  legenda  阅读(881)  评论(0编辑  收藏  举报