Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace PointInTheFigure
- {
- using System;
- public static class PointInTheFigure
- {
- public static void Main()
- {
- int h = int.Parse(Console.ReadLine());
- int x = int.Parse(Console.ReadLine());
- int y = int.Parse(Console.ReadLine());
- bool border = (y == 0 && InRange(x, 0, 3 * h)); // horizonal bottom border
- border = border || ((x == 0 || x == 3 * h) && InRange(y, 0, h)); // add bottom vertical borders
- border = border || ((y == h) && (InRange(x, 0, h) || InRange(x, 2 * h, 3 * h))); // add top horizontal borders
- border = border || ((x == h || x == 2 * h) && InRange(y, h, 4 * h));// add top vertical borders
- border = border || ((y == 4 * h) && InRange(x, h, 2 * h)); // add top horizontal border
- if (border) { Console.WriteLine("border"); return; }
- bool inside = InRange(x, 0, 3 * h) && InRange(y, 0, h); // in base
- inside = inside || (InRange(x, h, 2 * h) && InRange(y, 0, 4 * h)); // add in pillar
- if (inside)
- {
- Console.WriteLine("inside");
- }
- else
- {
- Console.WriteLine("outside");
- }
- //bool outR1 = x < 0 || 3 * h < x || y < 0 || h < y;
- //bool outR2 = x < h || 2 * h < x || y < h || 4 * h < y;
- //bool inR1 = 0 < x && x < 3 * h && 0 < y && y < h;
- //bool inR2 = h < x && x < 2 * h && h < y && y < 4 * h;
- //bool commonBorder = (x > h && x < 2 * h) && y == h;
- //if (outR1 && outR2)
- //{
- // Console.WriteLine("outside");
- //}
- //else if (inR1 || inR2 || commonBorder)
- //{
- // Console.WriteLine("inside");
- //}
- //else
- //{
- // Console.WriteLine("border");
- //}
- }
- public static bool InRange(double x, double x1, double x2) => (Math.Min(x1, x2) <= x) && (x <= Math.Max(x1, x2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement