Advertisement
BSO90

Additional NON-Required Odd and Even Product

May 11th, 2021
728
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.  
  4. namespace Additional_NON_Required_Problem_Odd_and_Even_Product
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var numbers = Console.ReadLine().Split();
  11.             double oddElementsProduct = 1;
  12.             double evenElementsProduct = 1;
  13.             int counter = 1;
  14.             foreach (var number in numbers)
  15.             {
  16.                 int currElement = int.Parse(number);
  17.                 if (counter % 2 != 0)
  18.                 {
  19.                     oddElementsProduct *= currElement;
  20.                 }
  21.                 else
  22.                 {
  23.                     evenElementsProduct *= currElement;
  24.                 }
  25.  
  26.                 counter++;
  27.  
  28.             }
  29.  
  30.             if (oddElementsProduct == evenElementsProduct)
  31.             {
  32.                 Console.WriteLine("result: yes");
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine("result: no");
  37.             }
  38.         }
  39.     }
  40. }
  41.  
  42.            
  43.  
  44.    
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement