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