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.Text;
- using System.Threading.Tasks;
- namespace PointInRectangle
- {
- public class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ');
- int topLeftX = int.Parse(input[0]);
- int topLeftY = int.Parse(input[1]);
- int bottomRightX = int.Parse(input[2]);
- int bottomRightY = int.Parse(input[3]);
- Point a = new Point(topLeftX, topLeftY);
- Point b = new Point(bottomRightX, bottomRightY);
- Rectangle rec = new Rectangle(a, b);
- int N = int.Parse(Console.ReadLine());
- for (int i = 0; i < N; i++)
- {
- string[] coords = Console.ReadLine().Split(' ');
- int givenPointX = int.Parse(coords[0]);
- int givenPointY = int.Parse(coords[1]);
- Point givenPoint = new Point(givenPointX, givenPointY);
- bool rr = rec.Contains(givenPoint);
- Console.WriteLine(rr);
- }
- }
- }
- }
- namespace PointInRectangle
- {
- public class Point
- {
- public int XCoordinate { get; set; }
- public int YCoordinate { get; set; }
- public Point(int xCoordinate, int yCoordinate)
- {
- this.XCoordinate = xCoordinate;
- this.YCoordinate = yCoordinate;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PointInRectangle
- {
- public class Rectangle
- {
- public Point Point1 { get; set; }
- public Point Point2 { get; set; }
- public Rectangle(Point point1, Point point2)
- {
- this.Point1 = point1;
- this.Point2 = point2;
- }
- public bool Contains(Point point)
- {
- if (point.XCoordinate < Point1.XCoordinate || point.XCoordinate > Point2.XCoordinate)
- {
- return false;
- }
- else if (point.YCoordinate < Point1.YCoordinate || point.YCoordinate > Point2.YCoordinate)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement