Advertisement
Guest User

rjyfdhtfsxcfsgfeasgaefggeagea

a guest
Oct 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _06.Rectangle_Position
  8. {
  9. class Program
  10. {
  11. class Rectangle
  12. {
  13. public int Left { get; set; }
  14. public int Top { get; set; }
  15. public int Width { get; set; }
  16. public int Height { get; set; }
  17. }
  18.  
  19. class Rectanble2
  20. {
  21. public int Right { get; set; }
  22. public int Bottom { get; set; }
  23. }
  24.  
  25. static bool IsInside(Rectangle a, Rectangle b)
  26. {
  27. int right1 = a.Left + a.Width;
  28. int bottom1 = a.Top + a.Height;
  29. int right2 = b.Left + b.Width;
  30. int bottom2 = b.Top + b.Height;
  31.  
  32. if (((a.Left >= b.Left) && (right1 <= right2)) && (a.Top <= b.Top) && (bottom1 <= bottom2))
  33. {
  34. return true;
  35. }
  36. else
  37. {
  38. return false;
  39. }
  40. }
  41.  
  42. static void Main(string[] args)
  43. {
  44. string[] p1Values = Console.ReadLine().Split();
  45. Rectangle r1 = new Rectangle
  46. {
  47. Left = int.Parse(p1Values[0]),
  48. Top = int.Parse(p1Values[1]),
  49. Width = int.Parse(p1Values[2]),
  50. Height = int.Parse(p1Values[3])
  51. };
  52. string[] p2Values = Console.ReadLine().Split();
  53. Rectangle r2 = new Rectangle
  54. {
  55. Left = int.Parse(p2Values[0]),
  56. Top = int.Parse(p2Values[1]),
  57. Width = int.Parse(p2Values[2]),
  58. Height = int.Parse(p2Values[3]),
  59. };
  60.  
  61. if (IsInside(r1,r2) == true)
  62. {
  63. Console.WriteLine("Inside");
  64. }
  65. else
  66. {
  67. Console.WriteLine("Not inside");
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement