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)
- {
- int n = int.Parse(Console.ReadLine());
- double OddSum = 0;
- var OddMin = double.MaxValue;
- var OddMax = double.MinValue;
- double EvenSum = 0.0;
- var EvenMin = double.MaxValue;
- var EvenMax = double.MinValue;
- for (double i = 0; i < n; i++)
- {
- var element = double.Parse(Console.ReadLine());
- if (i % 2 == 0)
- {
- OddSum += element;
- if (OddMin > element)
- OddMin = element;
- if (OddMax < element)
- OddMax = element;
- }
- else
- {
- EvenSum += element;
- if (EvenMin > element)
- EvenMin = element;
- if (EvenMax < element)
- EvenMax = element;
- }
- }
- Console.WriteLine("oddsum = {0} ",(OddSum));
- if (OddMin > 1000000000.0)
- {
- Console.WriteLine("oddmin=No");
- }
- else
- Console.WriteLine("oddmin = {0} ",(OddMin));
- if (OddMax < -1000000000.0)
- {
- Console.WriteLine("oddmax=No");
- }
- else
- Console.WriteLine("oddmax = {0} ", (OddMax));
- Console.WriteLine("evensum = {0} ", (EvenSum));
- if (EvenMin > 1000000000.0)
- {
- Console.WriteLine("evenmin=No"); }
- else
- Console.WriteLine("evenmin = {0} ", (EvenMin));
- if (EvenMax < -1000000000.0)
- {
- Console.WriteLine("evenmax=No");
- }
- else
- Console.WriteLine("evenmax = {0} ", (EvenMax));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment