Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OddEvenProductV2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n=Integer.parseInt(scanner.nextLine());
- int productOfEven=1;
- int productOfOdd=1;
- for (int i = 0; i < n ; i++) {
- int number=Integer.parseInt(scanner.nextLine());
- if (i%2==0) {
- productOfEven=productOfEven*number;
- }
- else {
- productOfOdd=productOfOdd*number;
- }
- }
- if (productOfEven==productOfOdd) {
- System.out.printf("yes %d",productOfEven).println();
- }
- else {
- System.out.printf("no %d %d",productOfEven,productOfOdd);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement