Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace OddEqualsEven
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10. int[] numbers = new int[n];
  11.  
  12. for (int i = 0; i < n; i++)
  13. {
  14. numbers[i] = int.Parse(Console.ReadLine());
  15. }
  16.  
  17. int productOdd = 1, productEven = 1;
  18. for (int i = 0; i < numbers.Length; i++)
  19. {
  20. if (i % 2 == 0)
  21. {
  22. productOdd *= numbers[i];
  23. }
  24. else
  25. {
  26. productEven *= numbers[i];
  27. }
  28. }
  29.  
  30. if (productEven == productOdd)
  31. {
  32. Console.WriteLine("yes {0}", productEven);
  33. }
  34. else
  35. {
  36. Console.WriteLine("no {0} {1}", productOdd, productEven);
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement