Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace tESt
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- double oddSum = 0;
- double oddMin = int.MaxValue;
- double oddMax = int.MinValue;
- double evenSum = 0;
- double evenMin = int.MaxValue;
- double evenMax = int.MinValue;
- for (int i = 1; i < n + 1; i++)
- {
- var num = double.Parse(Console.ReadLine());
- if (i % 2 != 0) // odd
- {
- oddSum = oddSum + num;
- if (num <= oddMin) // ODD MIN
- {
- oddMin = num;
- }
- if (num >= oddMax) // ODD MAX
- {
- oddMax = num;
- }
- }
- else // even
- {
- evenSum = evenSum + num;
- if (num <= evenMin) // EVEN MIN
- {
- evenMin = num;
- }
- if (num >=evenMax) // EVEN MAX
- {
- evenMax = num;
- }
- }
- }
- Console.WriteLine($"OddSum={oddSum},");
- if (oddMin != int.MaxValue)
- {
- Console.WriteLine($"OddMin={oddMin},");
- }
- else
- {
- Console.WriteLine("OddMin=No,");
- }
- if (oddMax != int.MinValue)
- {
- Console.WriteLine($"OddMax={oddMax},");
- }
- else
- {
- Console.WriteLine($"OddMax=No,");
- }
- Console.WriteLine($"evensum={evenSum},");
- if (evenMin != int.MaxValue)
- {
- Console.WriteLine($"EvenMin={evenMin},");
- }
- else
- {
- Console.WriteLine($"EvenMin=No,");
- }
- if (evenMax != int.MinValue)
- {
- Console.WriteLine($"EvenMax={evenMax},");
- }
- else
- {
- Console.WriteLine($"EvenMax=No,");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment