Advertisement
ibakyrdjiev

Untitled

Jul 9th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class OddAndEvenProduct
  9. {
  10.     static void Main()
  11.     {
  12.         int odd = 1;
  13.         int even = 1;
  14.         string input = Console.ReadLine();
  15.         string[] spaces = input.Split(' ');
  16.         int[] array = new int[spaces.Length];
  17.         for (int i =0; i < array.Length; i++)
  18.         {
  19.             array[i] = int.Parse(spaces[i]);
  20.             if (i % 2 == 0)
  21.             {
  22.                 odd *= array[i];
  23.             }
  24.             if (i % 2 == 1)
  25.             {
  26.                 even *= array[i];
  27.             }
  28.         }
  29.         if (even == odd)
  30.         {
  31.             Console.WriteLine("Yes");
  32.             Console.WriteLine("product = {0}", odd);
  33.         }
  34.         else
  35.         {
  36.             Console.WriteLine("No");
  37.             Console.WriteLine("odd_product = {0}", odd);
  38.             Console.WriteLine("even_product = {0}", even);
  39.         }
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement