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 Структура.Многоугольники
- {
- struct Polygon
- {
- double[] intCoordX;
- double[] intCoordY;
- double dblLineThickness;
- uint intLineColor;
- bool blnIsFilled;
- public Polygon(double[] x, double[] y, double Thick, uint Color, bool Fill)
- {
- intCoordX = x;
- intCoordY = y;
- dblLineThickness = Thick;
- intLineColor = Color;
- blnIsFilled = Fill;
- }
- public bool Check()
- {
- if (ifEqualSides() && ifFilled() && ifHaveFourSides())
- return true;
- else
- return false;
- }
- bool ifEqualSides()
- {
- if (((Math.Sqrt(Math.Pow(intCoordY[1] - intCoordY[0], 2) + Math.Pow(intCoordX[1] - intCoordX[0], 2)) == Math.Sqrt(Math.Pow(intCoordY[2] - intCoordY[1], 2) + Math.Pow(intCoordX[2] - intCoordX[1], 2))) && (Math.Sqrt(Math.Pow(intCoordY[2] - intCoordY[1], 2) + Math.Pow(intCoordX[2] - intCoordX[1], 2)) == Math.Sqrt(Math.Pow(intCoordY[3] - intCoordY[2], 2) + Math.Pow(intCoordX[3] - intCoordX[2], 2))) && (Math.Sqrt(Math.Pow(intCoordY[3] - intCoordY[2], 2) + Math.Pow(intCoordX[3] - intCoordX[2], 2)) == Math.Sqrt(Math.Pow(intCoordY[0] - intCoordY[3], 2) + Math.Pow(intCoordX[0] - intCoordX[3], 2)))))
- return true;
- else
- return false;
- }
- bool ifFilled()
- {
- return blnIsFilled;
- }
- int SideCount()
- {
- return intCoordX.Length;
- }
- bool ifHaveFourSides()
- {
- if (SideCount() == 4)
- return true;
- else
- return false;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите количество многоугольников");
- int intPolyCount = int.Parse(Console.ReadLine());
- Polygon[] arrPolygon = new Polygon[intPolyCount];
- for (int intCurPoly = 0; intCurPoly < arrPolygon.Length; intCurPoly++)
- {
- Console.WriteLine("=== Многоугольник {0} ===", intCurPoly + 1);
- Console.WriteLine("Введите количество вершин");
- int intCount = int.Parse(Console.ReadLine());
- double[] arrX = new double[intCount];
- double[] arrY = new double[intCount];
- Console.WriteLine("Введите координаты вершин многоугольника (по часовой стрелке):");
- for (int intC = 0; intC < intCount; intC++)
- {
- Console.Write("X: ");
- arrX[intC] = int.Parse(Console.ReadLine());
- Console.Write("Y: ");
- arrY[intC] = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("Введите толщину линий");
- double intLineThickness = double.Parse(Console.ReadLine());
- Console.WriteLine("Введите цвет линий");
- uint intLineColor = uint.Parse(Console.ReadLine());
- Console.WriteLine("Введите наличие заливки (true/false)");
- bool ifFilled = bool.Parse(Console.ReadLine());
- arrPolygon[intCurPoly] = new Polygon(arrX, arrY, intLineThickness, intLineColor, ifFilled);
- }
- int intCur = 0;
- foreach (Polygon objPoly in arrPolygon)
- {
- if (objPoly.Check())
- Console.WriteLine("{0}) Многоугольник прошел проверку!", intCur+1);
- else
- Console.WriteLine("{0}) Многоугольник не прошел проверку!", intCur+1);
- intCur++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement