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 Odd_Even_Elements
- {
- class OddEvenElements
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string[] elements = input.Split(' ');
- decimal oddSum = 0;
- decimal evenSum = 0;
- decimal oddMax = decimal.MinValue;
- decimal oddMin = decimal.MaxValue;
- decimal evenMax = decimal.MinValue;
- decimal evenMin = decimal.MaxValue;
- bool odd = true;
- if (input == "")
- {
- elements = new string[0];
- }
- for(int i = 0; i < elements.Length; i++)
- {
- decimal element = decimal.Parse(elements[i]);
- if(odd)
- {
- oddSum += element;
- oddMin = Math.Min(oddMin, element);
- oddMax = Math.Max(oddMax, element);
- }
- else
- {
- evenSum += element;
- evenMin = Math.Min(evenMin, element);
- evenMax = Math.Max(evenMax, element);
- }
- odd = !odd;
- }
- if(elements.Length == 0)
- {
- Console.WriteLine("OddSum=No, OddMin=No, OddMax=No, EvenSum=No, EvenMin=No, EvenMax=No");
- }
- else if (elements.Length == 1)
- {
- Console.WriteLine("OddSum={0}, OddMin={1}, OddMax={2}, EvenSum=No, EvenMin=No, EvenMax=No", (double)oddSum, (double)oddMin, (double)oddMax);
- }
- else
- {
- Console.WriteLine("OddSum={0}, OddMin={1}, OddMax={2}, EvenSum={3}, EvenMin={4}, EvenMax={5}", (double)oddSum, (double)oddMin, (double)oddMax, (double)evenSum, (double)evenMin, (double)evenMax);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment