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