예제 #1
0
        public void taskRTriangle(TextBox field, int M)
        {
            field.Text = "Все прямоугольные треугольники:\r\n";

            RightTriangle[] triangle = new RightTriangle[M];

            int minH = 0;

            for (int i = 0; i < M; i++)
            {
                float s1 = (float)rand.Next(15) + 1;
                float s2 = (float)rand.Next(15) + 1;

                triangle[i] = new RightTriangle(s1, s2);

                if (triangle[i].getHypotenuse() < triangle[minH].getHypotenuse())
                {
                    minH = i;
                }

                field.Text += "Треугольник №" + (i + 1) + "\r\n" + triangle[i].getInfo();
            }

            field.Text += "\r\nТреугольник с минимальной гипотенузой:\r\n";
            field.Text += "Треугольник №" + (minH + 1) + "\r\n" + triangle[minH].getInfo();
        }
예제 #2
0
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            EquilateralTriangle tr1 = new EquilateralTriangle(10, 0.3);

            Debug.WriteLine("Equilateral triangle Area: " + tr1.Area()
                            + " Perimetr: " + tr1.Perimetr() + "\n");

            RightTriangle tr2 = new RightTriangle(10, 11);

            Debug.WriteLine("Right triangle Area: " + tr2.Area()
                            + " Perimetr: " + tr2.Perimetr() + "\n");
        }
예제 #3
0
        public void loadFile(String path)
        {
            FileStream   fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader reader     = new BinaryReader(fileStream);

            int choProchest = reader.ReadInt32();
            int length      = reader.ReadInt32();

            Triangle[] temp = new Triangle[length];

            int i = 0;

            while (fileStream.CanRead && i < length)
            {
                float a = (float)reader.ReadDouble();
                float b = (float)reader.ReadDouble();
                float c = (float)reader.ReadDouble();
                temp[i] = new Triangle(a, b, c);
                i++;
            }

            if (choProchest == 1)
            {
                triangles = temp;
            }
            else if (choProchest == 2)
            {
                RightTriangle[] temp2 = new RightTriangle[length];

                for (int j = 0; j < length; j++)
                {
                    temp2[j] = new RightTriangle(temp[i].a, temp[i].b);
                }

                rTriangles = temp2;
            }
        }