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 NumsEndingIn7
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.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) // even
- {
- if (evenMax < num)
- {
- evenMax = num;
- }
- if (evenMin > num)
- {
- evenMin = num;
- }
- evenSum += num;
- }
- else // odd
- {
- if (oddMax < num)
- {
- oddMax = num;
- }
- if (oddMin > num)
- {
- oddMin = num;
- }
- oddSum += num;
- }
- }
- if (oddMax == Double.MinValue)
- {
- Console.WriteLine($"OddSum={oddSum},\nOddMin=No,\nOddMax=No");
- }
- else
- {
- Console.WriteLine($"OddSum={oddSum},\nOddMin={oddMin},\nOddMax={oddMax}");
- }
- if (evenMax == Double.MinValue)
- {
- Console.WriteLine($"EvenSum={evenSum},\nEvenMin=No,\nEvenMax=No");
- }
- else
- {
- Console.WriteLine($"EvenSum={evenSum},\nEvenMin={evenMin},\nEvenMax={evenMax}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment