Advertisement
TodorovP

11 Odd Even Position

Feb 5th, 2018
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Odd___Even_Position_11
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.  
  15.             double oddSum = 0;
  16.             double oddMin = double.MinValue;
  17.             double oddMax = double.MaxValue;            
  18.             double evenSum = 0;
  19.             double evenMin = -1000000000.0;
  20.             double evenMax = 1000000000.0;
  21.  
  22.             double oddMin1 = oddMin;
  23.             double oddMax1 = oddMax;
  24.             double evenMin2 = evenMin;
  25.             double evenMax2 = evenMax;
  26.  
  27.             if (n != 0)
  28.             {
  29.                 for (int i = 1; i <= 2; i++)
  30.                 {
  31.                     var num12 = double.Parse(Console.ReadLine());
  32.                     if (i == 1)
  33.                     {
  34.                         oddSum = num12;
  35.                         oddMin = num12;
  36.                         oddMax = num12;
  37.                     }
  38.                     else
  39.                     {
  40.                         evenSum = num12;
  41.                         evenMin = num12;
  42.                         evenMax = num12;
  43.                     }
  44.                     if (n == 1) break;
  45.                 }
  46.  
  47.                 if (n > 2)
  48.                 {
  49.                     for (int i = 3; i <= n; i++)
  50.                     {
  51.                         var num3 = double.Parse(Console.ReadLine());
  52.                         if (i % 2 == 0)
  53.                         {
  54.                             evenSum += num3;
  55.                             if (num3 < evenMin) evenMin = num3;
  56.                             if (num3 > evenMax) evenMax = num3;
  57.                         }
  58.                         else
  59.                         {
  60.                             oddSum += num3;
  61.                             if (num3 < oddMin) oddMin = num3;
  62.                             if (num3 > oddMax) oddMax = num3;
  63.                         }
  64.                     }
  65.                 }
  66.             }
  67.            
  68.             Console.WriteLine($"OddSum={oddSum}");
  69.             if (oddMin == oddMin1) Console.WriteLine($"OddMin=No");
  70.             else Console.WriteLine($"OddMin={oddMin}");
  71.             if (oddMax == oddMax1) Console.WriteLine($"OddMax=No");
  72.             else Console.WriteLine($"OddMax={oddMax}");
  73.             Console.WriteLine($"EvenSum={evenSum}");
  74.             if (evenMin == evenMin2) Console.WriteLine($"EvenMin=No");
  75.             else Console.WriteLine($"EvenMin={evenMin}");
  76.             if (evenMax == evenMax2) Console.WriteLine($"EvenMax=No");
  77.             else Console.WriteLine($"EvenMax={evenMax}");
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement