TodorMitev

task03_bnoi_45

Jan 9th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Task03
  7. {
  8.     class Task03
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             uint m = uint.Parse(Console.ReadLine());
  13.             uint n = uint.Parse(Console.ReadLine());
  14.             List<uint> evenNumbers = new List<uint>();
  15.             if ((0 < m) && (m < n) && (n < 2000000000))
  16.             {
  17.                 for (uint i = m; i <= n; i++)
  18.                 {
  19.                     if (i % 2 == 0)
  20.                         evenNumbers.Add(i);
  21.                 }
  22.                 uint sum = 0;
  23.                 int count = 0;
  24.                 foreach (var item in evenNumbers)
  25.                 {
  26.                     sum += item;
  27.                     count++;
  28.                 }
  29.                 decimal result = sum / count;
  30.                 Console.WriteLine(result);
  31.             }
  32.             else
  33.                 Console.WriteLine("Bad Input!");
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment