您的位置:首页 > 其它

hdoj Secret Number

2014-12-01 13:20 134 查看

Secret Number

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 27   Accepted Submission(s) : 10

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

有一天, KIKI 收到一张奇怪的信, 信上要KIKI 计算出给定数各个位上数字为偶数的和.

eg. 5548

结果为12 , 等于 4 + 8

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

Input

输入数据有多组,每组占一行,只有一个数字,保证数字在INT范围内.

Output

对于每组输入数据,输出一行,每两组数据之间有一个空行.

Sample Input

415326
3262


Sample Output

12

10

#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
void intoint(int n){
     int s=0,q,;
     while(n){
       q=n%10;
       n=n/10;
       if(q%2==0)
       s=s+q;}
       printf("%d\n",s); 
     }
int main()
{
    int n,flag=0;
    while(scanf("%d",&n)!=EOF){
       if(flag)printf("\n");//注意空格位置
    intoint(n);
    flag=1;}
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: