SHARE
TWEET

Untitled

a guest Jul 14th, 2016 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class OddEvenPosition
  9. {
  10.     static void Main(string[] args)
  11.     {
  12.         int n = int.Parse(Console.ReadLine());
  13.         double[] array = new double[n];
  14.         double oddsum = 0.0;
  15.         double oddmin = double.MaxValue;
  16.         double oddmax = double.MinValue;
  17.         double evensum = 0.0;
  18.         double evenmin = double.MaxValue;
  19.         double evenmax = double.MinValue;
  20.  
  21.         for (int i = 0; i < n; i++)
  22.         {
  23.             array[i] = double.Parse(Console.ReadLine());
  24.         }
  25.  
  26.         for (int i = 0; i < array.Length; i++)
  27.         {
  28.             if (!(i % 2 == 0))
  29.             {
  30.                 evensum += array[i];
  31.                 evenmin = evenmin > array[i] ? array[i] : evenmin;
  32.                 evenmax = evenmax < array[i] ? array[i] : evenmax;
  33.             }
  34.             else
  35.             {
  36.                 oddsum += array[i];
  37.                 oddmin = oddmin > array[i] ? array[i] : oddmin;
  38.                 oddmax = oddmax < array[i] ? array[i] : oddmax;
  39.             }
  40.         }
  41.  
  42.         Console.WriteLine("OddSum={0},", oddsum);
  43.         Console.WriteLine("OddMin={0},", oddmin == double.MaxValue ? "No" : oddmin.ToString());
  44.         Console.WriteLine("OddMax={0},", oddmax == double.MinValue ? "No" : oddmax.ToString());
  45.         Console.WriteLine("EvenSum={0},", evensum);
  46.         Console.WriteLine("EvenMin={0},", evenmin == double.MaxValue ? "No" : evenmin.ToString());
  47.         Console.WriteLine("EvenMax={0}", evenmax == double.MinValue ? "No" : evenmax.ToString());
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top