Пример #1
0
        private void ToTrinomialQuadratic_Click(object sender, EventArgs e)
        {
            Trinomial bgn = new Trinomial(1, 1, 1);

            progressBar.Value = 0;
            Display.Text      = "Trinomial-Quadratic Converter   (C)Michael Wang\r\n";
            try
            {
                bgn           = new Trinomial(InputBox.Text);
                Display.Text += "Begining Value:\r\n" + bgn.AsString() + "\r\n";
                Faker.NewLine(Faker.question + ". Convert the Trinomial, " + bgn.AsString() + " to a quadratic");
                Faker.question++;
            }
            catch
            {
                Display.Text += "Output:\r\nThis is not a trinomial;Invalid Format;\r\n" +
                                "Should be of: a(X+b)(X+c)(X+d)";
                progressBar.Value = progressBar.Maximum;
                return;
            }
            TrinomialQuadratic otp = new TrinomialQuadratic(bgn.d * bgn.c + bgn.a + bgn.b, bgn.a * bgn.b + bgn.c * bgn.a + bgn.b * bgn.a,
                                                            bgn.c * bgn.a * bgn.b, bgn.d);

            Faker.NewLine("Work as in for a,b,c,d in ax^3+bx^2+cx+d");
            Faker.NewLine("a=" + bgn.d);
            Faker.NewLine("b=" + bgn.d + "*" + bgn.c + "+" + bgn.a + "+" + bgn.b + "=" + ((bgn.d * bgn.c) + bgn.a + bgn.b));
            Faker.NewLine("c=" + bgn.a + "*" + bgn.b + "+" + bgn.c + "*" + bgn.a + "+" + bgn.b + "*" + bgn.a + "=" + (bgn.a * bgn.b + bgn.c * bgn.a + bgn.b * bgn.a));
            Faker.NewLine("d=" + bgn.c + "*" + bgn.a + "*" + bgn.c + "=" + (bgn.c * bgn.a * bgn.b));
            Faker.NewLine("therfore =" + otp.AsString());
            Faker.NewLine("");
            Display.Text     += "Output:\r\n" + otp.AsString();
            progressBar.Value = progressBar.Maximum;
        }
Пример #2
0
        private void ToTrinomialButton_Click(object sender, EventArgs e)
        {
            TrinomialQuadratic bgn = new TrinomialQuadratic(1, 1, 1);

            Display.Text      = "Quadratic-Trinomial Converter   (C)Michael Wang\r\n";
            progressBar.Value = 0;
            try
            {
                bgn           = new TrinomialQuadratic(InputBox.Text);
                Display.Text += "Begining Value:\r\n" + bgn.AsString() + "\r\n";
                MessageBox.Show("This might take a while");
            }
            catch
            {
                Display.Text += "Output:\r\nThis is not a quadratic (trinomial);Invalid Format;\r\n" +
                                "Should be of: aX^3+bX^2+cX+d";
                progressBar.Value = progressBar.Maximum;
                return;
            }
            progressBar.Maximum = bgn.GetMaximumProgrss() * bgn.GetMaximumProgrss() * bgn.GetMaximumProgrss() * 8;
            for (int a = -bgn.GetMaximumProgrss(); a < bgn.GetMaximumProgrss(); a++)
            {
                for (int b = -bgn.GetMaximumProgrss(); b < bgn.GetMaximumProgrss(); b++)
                {
                    for (int c = -bgn.GetMaximumProgrss(); c < bgn.GetMaximumProgrss(); c++)
                    {
                        if (bgn.a == bgn.d * c + (a + b) && bgn.b == a * b + c * a + b * a &&
                            bgn.c == a * b * c)
                        {
                            progressBar.Value = progressBar.Maximum;
                            Trinomial otp = new Trinomial(a, b, c, bgn.d);
                            Display.Text += "Output:\r\n" + otp.AsString();
                            return;
                        }
                        progressBar.Value++;
                    }
                }
            }
            Display.Text     += "Output:\r\nThis quadratic must produce integer";
            progressBar.Value = progressBar.Maximum;
        }