hdu 2113 Secret Number (水题)

Secret Number

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 1   Accepted Submission(s) : 1
Problem Description
有一天, KIKI 收到一张奇怪的信, 信上要KIKI 计算出给定数各个位上数字为偶数的和.
eg. 5548
结果为12 , 等于 4 + 8

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

 

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

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

Sample Input
  
  
415326 3262
 

Sample Output
  
  
12 10
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int a;
int b[20];

int main()
{
    int i;
    int s;
    int cnt=0;
    while(scanf("%d",&a)==1)
    {
        memset(b,0,sizeof(0));
        s=0;
        i=0;
        while(a)
        {
            b[i++]=a%10;
            a=a/10;
        }
        for(int j=0; j<i; j++)
        {
            if(b[j]%2==0)
                s=s+b[j];
        }
        if(cnt==0)
        printf("%d\n",s);
        else
        printf("\n%d\n",s);
        cnt++;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值