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 _11.Odd___Even_Position
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- double oddSum = 0.0;
- double evenSum = 0.0;
- double oddMin = double.MaxValue;
- double oddMax = double.MinValue;
- 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 < evenMin)
- {
- evenMin = num;
- }
- if (num > evenMax)
- {
- evenMax = num;
- }
- }
- else
- {
- oddSum += num;
- if (num > oddMax) { oddMax = num; }
- if (num < oddMin) { oddMin = num; }
- }
- }
- if (n == 0)
- {
- Console.WriteLine("Oddsum = 0, Oddmin = No, Oddmax = No, Evensum = 0, Evenmin = No, Evenmax = No");
- }
- else if (n == 1)
- {
- Console.WriteLine($"Oddsum = {oddSum}, Oddmin = {oddMin}, Oddmax = {oddMax}, Evensum = 0, Evenmin = No, Evenmax = No");
- }
- else
- {
- Console.WriteLine($"Oddsum = {oddSum}, Oddmin = {oddMin}, Oddmax = {oddMax}, Evensum = {evenSum}, Evenmin = {evenMin}, Evenmax = {evenMax}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment