I

有一天, KIKI 收到一张奇怪的信, 信上要KIKI 计算出给定数各个位上数字为偶数的和.
eg. 5548
结果为12 , 等于 4 + 8

KIKI 很苦恼. 想请你帮忙解决这个问题.

Input输入数据有多组,每组占一行,只有一个数字,保证数字在INT范围内.Output对于每组输入数据,输出一行,每两组数据之间有一个空行.
Sample Input

415326
3262

Sample Output

12

10



#include<iostream>
using namespace std;
int main()
{
 int t = 0;
 int n;
 while (cin >> n)
 {
  if (t != 0)
  {
   cout << endl;
  }
  t = 1;
  int num = 0;
  while (n)
  {
   if (n % 10 % 2 == 0)
   {
    num += n % 10;
   }
   n /= 10;
  }
  cout << num << endl;
 }
}
原文地址:https://www.cnblogs.com/damaoranran/p/8718516.html