Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 6///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // System.Threading.Thread.CurrentThread.CurrentCulture =
- // System.Globalization.CultureInfo.InvariantCulture;
- //string input = Console.ReadLine();
- string[] inputNumbers = Console.ReadLine().Split(new string[] { " " },
- StringSplitOptions.RemoveEmptyEntries);
- decimal oddSum = 0m;// za decimal
- decimal oddMin = decimal.MaxValue;
- decimal oddMax = decimal.MinValue;
- decimal evenSum = 0m;
- decimal evenMin = decimal.MaxValue;
- decimal evenMax = decimal.MinValue;
- for (int i = 0; i < inputNumbers.Length; i++)
- {
- decimal element = decimal.Parse(inputNumbers[i]);
- if (i % 2 == 0) // tuk e ODD zashtoto sme v masiv i po4va ot indeks 0 1 2 3 4 5
- { // i realno po4vame ot 0 koeto e EVEN 2 4 6 8
- oddSum = oddSum + element;
- oddMin = Math.Min(oddMin, element);
- oddMax = Math.Max(oddMax, element);
- }
- else
- {
- evenSum = evenSum + element;
- evenMin = Math.Min(evenMin, element);
- evenMax = Math.Max(evenMax, element);
- }
- }
- if (inputNumbers.Length == 0)
- {
- Console.WriteLine(
- "OddSum=No, OddMin=No, OddMax=No, EvenSum=No, EvenMin=No, EvenMax=No");
- }
- else if (inputNumbers.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
Advertisement