Guest User

Untitled

a guest
Feb 20th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 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 ConsoleApplication44
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numToSum = int.Parse(Console.ReadLine());
  14.  
  15.  
  16.             double oddSum = 0.0;
  17.             double oddMin = double.MaxValue;
  18.             double oddMax = double.MinValue;
  19.  
  20.             double evenSum = 0.0;
  21.             double evenMin = double.MaxValue;
  22.             double evenMax = double.MinValue;
  23.  
  24.             for (int i = 1; i < numToSum + 1; i++)
  25.             {
  26.                 double currNum = double.Parse(Console.ReadLine());
  27.  
  28.  
  29.                 if (i % 2 == 0)
  30.                 {
  31.                     evenSum += currNum;
  32.  
  33.                     if (currNum < evenMin)
  34.                     {
  35.                         evenMin = currNum;
  36.                         //popravka
  37.                     }
  38.                     if (currNum > evenMax)
  39.                     {
  40.                         evenMax = currNum;
  41.                     }
  42.  
  43.                 }
  44.                 else if (i % 2 == 1)
  45.                 {
  46.                     oddSum += currNum;
  47.  
  48.                     if (currNum < oddMin)
  49.                     {
  50.                         oddMin = currNum;
  51.                     }
  52.                     if (currNum > oddMax)
  53.                     {
  54.                         oddMax = currNum;
  55.                     }
  56.                 }
  57.             }
  58.             //ODD
  59.             Console.WriteLine("OddSum={0}", oddSum);
  60.             if (oddMin==double.MaxValue)
  61.             {
  62.                 Console.WriteLine("OddMin=No");
  63.             }
  64.             else
  65.             {
  66.                 Console.WriteLine("OddMin={0}", oddMin);
  67.             }
  68.             if (oddMax==double.MinValue)
  69.             {
  70.                 Console.WriteLine("OddMax=No", oddMax);
  71.             }
  72.             else
  73.             {
  74.                 Console.WriteLine("OddMax ={0}", oddMax);
  75.             }
  76.             //EVEN
  77.             Console.WriteLine("EvenSum={0}", evenSum);
  78.             if (evenMin==double.MaxValue)
  79.             {
  80.                 Console.WriteLine("EvenMin=No");
  81.             }
  82.             else
  83.             {
  84.                 Console.WriteLine("EvenMin={0}", evenMin);
  85.             }
  86.             if (evenMax==double.MinValue)
  87.             {
  88.                 Console.WriteLine("EvenMax=No");
  89.             }
  90.             else
  91.             {
  92.                 Console.WriteLine("EvenMax={0}", evenMax);
  93.             }
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment