ZZULIOJ 1085: 求奇数的乘积(多实例测试),Java

1085: 求奇数的乘积(多实例测试)

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while(cin.hasNext())
        {
            int n=cin.nextInt();
            int result=1;
            for(int i=1;i<=n;i++)
            {
                int x=cin.nextInt();
                if(x%2!=0) result*=x;
            }
            System.out.println(result);
        }
    }
}
上一篇:工作中常用到的一些方法C#


下一篇:PAT甲级1085 Perfect Sequence :[C++题解]双指针