Advertisement
n4wn4w

2zadacha6variant

Mar 18th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 KB | None | 0 0
  1. 6///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //   System.Threading.Thread.CurrentThread.CurrentCulture =
  3.             //  System.Globalization.CultureInfo.InvariantCulture;
  4.  
  5.             //string input = Console.ReadLine();
  6.  
  7.             string[] inputNumbers = Console.ReadLine().Split(new string[] { " " },
  8.                      StringSplitOptions.RemoveEmptyEntries);
  9.  
  10.             decimal oddSum = 0m;// za decimal
  11.             decimal oddMin = decimal.MaxValue;
  12.             decimal oddMax = decimal.MinValue;
  13.             decimal evenSum = 0m;
  14.             decimal evenMin = decimal.MaxValue;
  15.             decimal evenMax = decimal.MinValue;
  16.  
  17.  
  18.             for (int i = 0; i < inputNumbers.Length; i++)
  19.             {
  20.                 decimal element = decimal.Parse(inputNumbers[i]);
  21.                 if (i % 2 == 0)   // tuk e ODD zashtoto sme v masiv i po4va ot indeks 0 1 2 3 4 5
  22.                 {                 // i realno po4vame ot 0 koeto e EVEN 2 4 6 8
  23.                     oddSum = oddSum + element;
  24.                     oddMin = Math.Min(oddMin, element);
  25.                     oddMax = Math.Max(oddMax, element);
  26.                 }
  27.                 else
  28.                 {
  29.                     evenSum = evenSum + element;
  30.                     evenMin = Math.Min(evenMin, element);
  31.                     evenMax = Math.Max(evenMax, element);
  32.                 }
  33.  
  34.             }
  35.  
  36.             if (inputNumbers.Length == 0)
  37.             {
  38.                 Console.WriteLine(
  39.                     "OddSum=No, OddMin=No, OddMax=No, EvenSum=No, EvenMin=No, EvenMax=No");
  40.             }
  41.             else if (inputNumbers.Length == 1)
  42.             {
  43.                 Console.WriteLine(
  44.                     "OddSum={0}, OddMin={1}, OddMax={2}, EvenSum=No, EvenMin=No, EvenMax=No",
  45.                     (double)oddSum, (double)oddMin, (double)oddMax);
  46.             }
  47.             else
  48.             {
  49.                 Console.WriteLine(
  50.                     "OddSum={0}, OddMin={1}, OddMax={2}, EvenSum={3}, EvenMin={4}, EvenMax={5}",
  51.                     (double)oddSum, (double)oddMin, (double)oddMax,
  52.                     (double)evenSum, (double)evenMin, (double)evenMax);
  53.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement