[HDU] [2006] Product of Odd Numbers

Problem Description

Loading...

Problem Analysis

Back then I still used %2 to tell whether a number was odd. But… I’m not changing it.
Keeping it as a memento.

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include<stdio.h>
int main() {
    int n,i,x,s;
    while(scanf("%d",&n)!=EOF) {
        s=1;
        for(i=0; i<n; i++) {

            scanf("%d",&x);
            if(x%2!=0)
                s=s*x;
        }
        printf("%d\n",s);
    }
    return 0;
}

Loading...