Advertisement
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 _11_OddEvenPosition
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- double oddMin = double.MaxValue;
- double oddMax = double.MinValue;
- double oddSum = 0;
- double evenMin = double.MaxValue;
- double evenMax = double.MinValue;
- double evenSum = 0;
- Calc(n, ref oddMin, ref oddMax, ref oddSum, ref evenMin, ref evenMax, ref evenSum);
- PrintOdd(oddMin, oddMax, oddSum);
- PrintEven(evenMin, evenMax, evenSum);
- }
- private static void PrintEven(double evenMin, double oddMax, double evenSum)
- {
- Console.WriteLine($"EvenSum={evenSum},");
- if (evenMin < double.MaxValue)
- {
- Console.WriteLine($"EvenMin={evenMin},");
- }
- else
- {
- Console.WriteLine("EvenMin=No,");
- }
- if (oddMax > double.MinValue)
- {
- Console.WriteLine($"EvenMax={oddMax},");
- }
- else
- {
- Console.WriteLine("EvenMax=No,");
- }
- }
- private static void PrintOdd(double oddMin, double oddMax, double oddSum)
- {
- Console.WriteLine($"OddSum={oddSum},");
- if (oddMin < double.MaxValue)
- {
- Console.WriteLine($"OddMin={oddMin},");
- }
- else
- {
- Console.WriteLine("OddMin=No,");
- }
- if (oddMax > double.MinValue)
- {
- Console.WriteLine($"OddMax={oddMax},");
- }
- else
- {
- Console.WriteLine("OddMax=No,");
- }
- }
- private static void Calc(int n, ref double oddMin, ref double oddMax, ref double oddSum, ref double evenMin, ref double evenMax, ref double evenSum)
- {
- for (int i = 1; i <= n; i++)
- {
- double num = double.Parse(Console.ReadLine());
- if (i % 2 != 0)
- {
- oddSum += num;
- if (num > oddMax)
- {
- oddMax = num;
- }
- if (num < oddMin)
- {
- oddMin = num;
- }
- }
- else
- {
- evenSum += num;
- if (num > evenMax)
- {
- evenMax = num;
- }
- if (num < evenMin)
- {
- evenMin = num;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement