Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApp1
- {
- class Input
- {
- private static IEnumerator<string> getin()
- {
- while (true)
- foreach (string s in Console.ReadLine().Split().Where(x => x.Length > 0))
- yield return s;
- }
- private IEnumerator<string> inp = getin();
- public string GetString() { inp.MoveNext(); return inp.Current; }
- public int GetInt() { return int.Parse(GetString()); }
- }
- class Program
- {
- static void Main()
- {
- Input cin = new Input();
- //int k = cin.GetInt();
- int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- int d = 0;
- for (int i = 0; i < a.Length; ++i)
- {
- if (a[i] % 2 == 0)
- d += a[i] * a[i];
- }
- Console.WriteLine("First case " + d);
- int b = a.Where(x => x % 2 == 0).Select(x => x * x).Aggregate((x, y) => x + y);
- Console.WriteLine("Second case " + b);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement