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 Odd_or_Even_Position
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- double sumEven = 0;
- double maxEven = int.MinValue;
- double minEven = int.MaxValue;
- double sumOdd = 0;
- double maxOdd = int.MinValue;
- double minOdd = int.MaxValue;
- if (num == 0)
- {
- Console.WriteLine("OddSum = 0");
- Console.WriteLine("OddMin = No");
- Console.WriteLine("OddMax = No");
- Console.WriteLine("EvenSum = 0");
- Console.WriteLine("EvenMin = No");
- Console.WriteLine("EvenMax = No");
- }
- else if (num == 1)
- {
- double current = double.Parse(Console.ReadLine());
- Console.WriteLine($"OddSum = {current}");
- Console.WriteLine($"OddMin = {current}");
- Console.WriteLine($"OddMax = {current}");
- Console.WriteLine("EvenSum = 0");
- Console.WriteLine("EvenMin = No");
- Console.WriteLine("EvenMax = No");
- }
- else if (num > 1)
- {
- for (int i = 1; i <= num; i++)
- {
- double current = double.Parse(Console.ReadLine());
- if (i % 2 != 0)
- {
- sumOdd += current;
- if (current > maxOdd)
- {
- maxOdd = current;
- }
- else if (current < minOdd)
- {
- minOdd = current;
- }
- }
- else
- {
- sumEven += current;
- if (current > maxEven)
- {
- maxEven = current;
- }
- else if (current < minEven)
- {
- minEven = current;
- }
- }
- Console.WriteLine($"OddSum = {sumOdd}");
- Console.WriteLine($"OddMin = {minOdd}");
- Console.WriteLine($"OddMax = {maxOdd}");
- Console.WriteLine($"EvenSum = {sumEven}");
- Console.WriteLine($"EvenMin = {minEven}");
- Console.WriteLine($"EvenMax = {maxEven}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement