Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Drawing;
- namespace ClassWork
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- var points = new Point[] { new Point(0, 0), new Point(0, 1) };
- foreach (var point in SecondTask(points))
- Console.WriteLine(point);
- }
- public static Point[] SecondTask(IEnumerable<Point> points)
- {
- return points
- .SelectMany(point =>
- {
- var newPoints = new List<Point>();
- for (int i = -1; i <= 1; i++)
- {
- for (int j = -1; j <= 1; j++)
- {
- newPoints.Add(new Point(point.X + i, point.Y + j));
- }
- }
- return newPoints;
- })
- .Distinct()
- .ToArray();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement