Advertisement
BSO90

Additional NON-Required Odd and Even Product

May 11th, 2021
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Additional_NON_Required_Problem_Odd_and_Even_Product
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var numbers = Console.ReadLine().Split();
  10.             double oddElementsProduct = 1;
  11.             double evenElementsProduct = 1;
  12.             int counter = 1;
  13.             foreach (var number in numbers)
  14.             {
  15.                 int currElement = int.Parse(number);
  16.                 if (counter % 2 != 0)
  17.                 {
  18.                     oddElementsProduct *= currElement;
  19.                 }
  20.                 else
  21.                 {
  22.                     evenElementsProduct *= currElement;
  23.                 }
  24.  
  25.                 counter++;
  26.             }
  27.  
  28.             if (oddElementsProduct == evenElementsProduct)
  29.             {
  30.                 Console.WriteLine("result: yes");
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("result: no");
  35.             }
  36.         }
  37.     }
  38. }
  39.  
  40.  
  41.  
  42.  
  43.            
  44.  
  45.    
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement