2006 ACM 求奇数的和

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2006
注意 sum=1,写在while 不然每次结果会累积

#include <stdio.h>
int main ()
{
    int n,arr,cot=0,sum;
    while(scanf("%d",&n)!=EOF)
    {
        sum=1;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&arr);
            if(arr%2)
                sum*=arr;
            }
                printf("%d\n",sum);
    }
}
posted @ 2018-08-10 10:39  CheeseIce  阅读(186)  评论(0编辑  收藏  举报