Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace 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;
- for (int i = 1; i <= n; i++)
- {
- double currentNum = double.Parse(Console.ReadLine());
- if (i % 2 == 1)
- {
- oddSum += currentNum;
- if (currentNum < oddMin)
- {
- oddMin = currentNum;
- }
- if (currentNum > oddMax)
- {
- oddMax = currentNum;
- }
- }
- else
- {
- evenSum += currentNum;
- if (currentNum < evenMin)
- {
- evenMin = currentNum;
- }
- if (currentNum > evenMax)
- {
- evenMax = currentNum;
- }
- }
- }
- if (n == 0)
- {
- Console.WriteLine("OddSum=0.00,\nOddMin=No,\nOddMax=No,");
- }
- else
- {
- Console.WriteLine($"OddSum={oddSum:f2},\nOddMin={oddMin:f2},\nOddMax={oddMax:f2},");
- }
- if (n <= 1)
- {
- Console.WriteLine("EvenSum=0.00,\nEvenMin=No,\nEvenMax=No");
- }
- else
- {
- Console.WriteLine($"EvenSum={evenSum:f2},\nEvenMin={evenMin:f2},\nEvenMax={evenMax:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement