Returns the product of an odd number.

Source: Internet
Author: User

Problem description

Give you n integers and calculate the product of all the odd numbers in them.

 

Input

The input data contains multiple test instances. Each test instance occupies one row. The first number of each row is N, indicating that there are n data in this group, followed by N integers, you can assume that each group of data must have at least one odd number.

 

Output

Output the product of all odd numbers in each group. For test instances, output a row.

 

Sample Input

3 1 2 3

4 2 3 4 5

 

Sample output

3

15

 

 1 #include <stdio.h> 2   3 int main(){ 4     int n; 5     int i; 6     int number; 7     int multi; 8       9     while((scanf("%d",&n))!=EOF){10         multi=1;11          12         for(i=0;i<n;i++){13             scanf("%d",&number);14              15             if(number%2==1)16                 multi*=number;17         }18          19         printf("%d\n",multi);20     }21      22      23     return 0;24 }

 

Returns the product of an odd number.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.