Some items--give you n integers, ask for the product of all the odd numbers in them.

Source: Internet
Author: User

Problem description gives you n integers, asking for the product of all the odd numbers in them. Input data contains multiple test instances, one row per test instance, and N for each row, indicating that there is a total of n for this group of data, followed by n integers, you can assume that each set of data must have at least one odd number. Output outputs the product of all the odd numbers in each set, and one row for the test instance. Sample Input

3 1 2 34 2 3 4 5
Sample Output
315

Code

#include <iostream>using namespace Std;int main () {    int n,m,i,s;    while (Cin>>n)    {        S=1;        for (i=0; i<n; i++)        {            cin>>m;            if (m%2!=0)                s=s*m;        }        cout<<s<<endl;    }    return 0;}

Learning sentiment: ashamed to say, because I did not examining, think that the number of data in each group is a meaning, not aware of the scope of the first digital limit, kept to how to end the cycle with Ctrl + Z, even the back with a double loop, know I find the answer from the Internet to analyze again ..... Alas, take this as a warning to yourself.


Some items--give you n integers, ask for the product of all the odd numbers in them.

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.