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 ConsoleApplication44
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numToSum = int.Parse(Console.ReadLine());
- double oddSum = 0.0;
- double oddMin = double.MaxValue;
- double oddMax = double.MinValue;
- double evenSum = 0.0;
- double evenMin = double.MaxValue;
- double evenMax = double.MinValue;
- for (int i = 1; i < numToSum + 1; i++)
- {
- double currNum = double.Parse(Console.ReadLine());
- if (i % 2 == 0)
- {
- evenSum += currNum;
- if (currNum < evenMin)
- {
- evenMin = currNum;
- //popravka
- }
- if (currNum > evenMax)
- {
- evenMax = currNum;
- }
- }
- else if (i % 2 == 1)
- {
- oddSum += currNum;
- if (currNum < oddMin)
- {
- oddMin = currNum;
- }
- if (currNum > oddMax)
- {
- oddMax = currNum;
- }
- }
- }
- //ODD
- Console.WriteLine("OddSum={0}", oddSum);
- if (oddMin==double.MaxValue)
- {
- Console.WriteLine("OddMin=No");
- }
- else
- {
- Console.WriteLine("OddMin={0}", oddMin);
- }
- if (oddMax==double.MinValue)
- {
- Console.WriteLine("OddMax=No", oddMax);
- }
- else
- {
- Console.WriteLine("OddMax ={0}", oddMax);
- }
- //EVEN
- Console.WriteLine("EvenSum={0}", evenSum);
- if (evenMin==double.MaxValue)
- {
- Console.WriteLine("EvenMin=No");
- }
- else
- {
- Console.WriteLine("EvenMin={0}", evenMin);
- }
- if (evenMax==double.MinValue)
- {
- Console.WriteLine("EvenMax=No");
- }
- else
- {
- Console.WriteLine("EvenMax={0}", evenMax);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment