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 Odd__Even_Elements_Sum_MIn_MAx
- {
- class Program
- {
- static void Main(string[] args)
- {
- System.Threading.Thread.CurrentThread.CurrentCulture =
- System.Globalization.CultureInfo.InvariantCulture;
- string[] numbers = Console.ReadLine().Split();
- decimal OddSum = 0;
- decimal OddMin = decimal.MaxValue;
- decimal OddMax = decimal.MinValue;
- decimal EvenSum = 0;
- decimal EvenMin = decimal.MaxValue;
- decimal EvenMax = decimal.MinValue;
- for (int i = 0; i < numbers.Length; i += 2)
- {
- decimal element = decimal.Parse(numbers[i]);
- OddSum = OddSum + element;
- }
- for (int i = 1; i < numbers.Length; i += 2)
- {
- decimal element = decimal.Parse(numbers[i]);
- EvenSum = EvenSum + element;
- }
- for (int i = 0; i < numbers.Length; i++)
- {
- for (int j = 0; j < numbers.Length; j += 2)
- {
- decimal element = decimal.Parse(numbers[j]);
- OddMin = Math.Min(OddMin, element);
- OddMax = Math.Max(OddMax, element);
- }
- for (int k = 1; k < numbers.Length; k += 2)
- {
- decimal element = decimal.Parse(numbers[k]);
- EvenMin = Math.Min(EvenMin, element);
- EvenMax = Math.Max(EvenMax, element);
- }
- }
- 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
Advertisement