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 _06.Rectangle_Position
- {
- class Program
- {
- class Rectangle
- {
- public int Left { get; set; }
- public int Top { get; set; }
- public int Width { get; set; }
- public int Height { get; set; }
- }
- class Rectanble2
- {
- public int Right { get; set; }
- public int Bottom { get; set; }
- }
- static bool IsInside(Rectangle a, Rectangle b)
- {
- int right1 = a.Left + a.Width;
- int bottom1 = a.Top + a.Height;
- int right2 = b.Left + b.Width;
- int bottom2 = b.Top + b.Height;
- if (((a.Left >= b.Left) && (right1 <= right2)) && (a.Top <= b.Top) && (bottom1 <= bottom2))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- static void Main(string[] args)
- {
- string[] p1Values = Console.ReadLine().Split();
- Rectangle r1 = new Rectangle
- {
- Left = int.Parse(p1Values[0]),
- Top = int.Parse(p1Values[1]),
- Width = int.Parse(p1Values[2]),
- Height = int.Parse(p1Values[3])
- };
- string[] p2Values = Console.ReadLine().Split();
- Rectangle r2 = new Rectangle
- {
- Left = int.Parse(p2Values[0]),
- Top = int.Parse(p2Values[1]),
- Width = int.Parse(p2Values[2]),
- Height = int.Parse(p2Values[3]),
- };
- if (IsInside(r1,r2) == true)
- {
- Console.WriteLine("Inside");
- }
- else
- {
- Console.WriteLine("Not inside");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement