public Detector(Polygon polygon) { Polygon = polygon; if (polygon.Area > 0) { // g = P - 1/2b + 1 Result = Polygon.Area - (Polygon.SidePointsCount / 2) + 1; } }
static void Main(string[] args) { try { ArgsReader ArgsReader = null; List<string> ReadData = new List<string>(); int PolygonsToTake = int.Parse(Console.ReadLine()); if (PolygonsToTake < 1 || PolygonsToTake > 100) { throw new Exception("Zly zakres. Liczba wielokatow powinna wynosic od 1 do 100"); } ReadData.Add(PolygonsToTake.ToString()); for (int i = 0; i < PolygonsToTake; i++) { int PointsCount = int.Parse(Console.ReadLine()); if (PointsCount < 0 || PointsCount > 200000) { throw new Exception("Zly zakres. Liczba wierzcholkow powinna wynosic od 0 do 200 000"); } ReadData.Add(PointsCount.ToString()); for (int j = 0; j < PointsCount; j++) { string Point = Console.ReadLine(); ReadData.Add(Point); } } ArgsReader = new ArgsReader(ReadData.ToArray()); foreach (var StringPoints in ArgsReader.PointSets) { var ConvertedPoints = PolygonConverter.FromPoints(StringPoints); var Polygon = new Polygon(ConvertedPoints); var Detector = new Detector(Polygon); Console.WriteLine(Detector.Result.ToString()); } } catch (Exception exception) { Console.WriteLine(exception.Message); } }