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___Even_Position
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = double.Parse(Console.ReadLine());
- double oddSum = 0.0;
- double evenSum = 0.0;
- var oddMin = double.MaxValue;
- var oddMax = double.MinValue;
- var evenMin = double.MaxValue;
- var evenMax = double.MinValue;
- for (var i = 1; i <= n; i++)
- {
- var num = double.Parse(Console.ReadLine());
- if (i % 2 == 0)
- {
- evenSum = evenSum + num;
- if (num > evenMax)
- {
- evenMax = num;
- }
- if (num < evenMin)
- {
- evenMin = num;
- }
- }
- else
- {
- oddSum = oddSum + num;
- if (num > oddMax)
- {
- oddMax = num;
- }
- if (num < oddMin)
- {
- oddMin = num;
- }
- }
- }
- Console.WriteLine("oddSum=" + oddSum);
- if (oddMin == double.MaxValue)
- { Console.WriteLine("oddMin=No"); }
- else
- { Console.WriteLine("oddMin=" + oddMin); }
- if (oddMax == double.MinValue)
- { Console.WriteLine("oddMax=No"); }
- else
- { Console.WriteLine("oddMax=" + oddMax); }
- Console.WriteLine("evenSum=" + evenSum);
- if (evenMin == double.MaxValue)
- { Console.WriteLine("evenMin=No"); }
- else
- { Console.WriteLine("evenMin =" + evenMin); }
- if (evenMax == double.MinValue)
- { Console.WriteLine("evenMax=No"); }
- else
- { Console.WriteLine("evenMax=" + evenMax); }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement