zl程序教程

您现在的位置是:首页 >  其它

当前栏目

求奇数的乘积

乘积 奇数
2023-09-27 14:23:03 时间

package com.test;

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
           Scanner sc=new Scanner(System.in);
           int r,result=1;
           while(sc.hasNextInt()){
           r=sc.nextInt();
           int a[]=new int[r];

           for(int i=0;i<r;i++){
               a[i]=sc.nextInt();
           }
           for(int s:a){
              if(s%2!=0) result*=s;
          }
           System.out.println(result);
           result=1;
     }
    }
}