Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _10.OddAndEvenProduct
- {
- class OddAndEvenProduct
- {
- static void Main()
- {
- Console.Write("Enter numbers separated by space: ");
- string[] numbers = Console.ReadLine().Split();
- int productEven = 1;
- int productOdd = 1;
- for (int i = 0; i <= numbers.Length - 1;)
- {
- productOdd *= Convert.ToInt32(numbers[i]);
- i += 2;
- }
- for (int j = 1; j <= numbers.Length - 1;)
- {
- productEven *= Convert.ToInt32(numbers[j]);
- j += 2;
- }
- bool equal = (productEven == productOdd);
- Console.WriteLine("Result: {0}.", equal);
- if (equal)
- {
- Console.WriteLine("Product: {0}.", productEven);
- }
- else
- {
- Console.WriteLine("Even product: {0}.", productEven);
- Console.WriteLine("Odd product: {0}.", productOdd);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement