예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Я хочу знайти рiшення системи:\n 1)системи двох лiнiйних рiвнянь з двома невiдомими  \n " +
                              "2) системи трьох лiнiйних рiвнянь з трьома невiдомими");
            int userChoice = Convert.ToInt32(Console.ReadLine());

            if (userChoice == 1)
            {
                double x1;
                double x2;

                Equation eq  = new Equation();
                IMatrix2 eq2 = (IMatrix2)eq;
                eq2.SetValues(ref eq);
                eq2.Solution(out x1, out x2);
                Console.WriteLine();
                eq2.EquationOutput();
                Console.WriteLine();

                Console.WriteLine($"x = {x1}, y = {x2}");
            }
            else if (userChoice == 2)
            {
                double x1;
                double x2;
                double x3;

                Equation eq  = new Equation();
                IMatrix3 eq3 = (IMatrix3)eq;
                eq3.SetValues(ref eq);
                eq3.Solution(out x1, out x2, out x3);
                Console.WriteLine();
                eq3.EquationOutput();

                Console.WriteLine($"x = {x1}, y = {x2}, z = {x3}");
            }
            else
            {
                Console.WriteLine("Спробуйте ще раз...");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("I want to find a solution of system of:\n 1) TWO linear equations \n 2) THREE linear equations");
            int userChoice = Convert.ToInt32(Console.ReadLine());

            if (userChoice == 1)
            {
                double x1;
                double x2;

                Equation   eq  = new Equation();
                IMatrix2x2 eq2 = (IMatrix2x2)eq;
                eq2.SetValues(ref eq);
                eq2.Solution(out x1, out x2);
                Console.WriteLine();
                eq2.EquationOutput();
                Console.WriteLine();

                Console.WriteLine($"x = {x1}, y = {x2}");
            }
            else if (userChoice == 2)
            {
                double x1;
                double x2;
                double x3;

                Equation   eq  = new Equation();
                IMatrix3x3 eq3 = (IMatrix3x3)eq;
                eq3.SetValues(ref eq);
                eq3.Solution(out x1, out x2, out x3);
                Console.WriteLine();
                eq3.EquationOutput();

                Console.WriteLine($"x = {x1}, y = {x2}, z = {x3}");
            }
            else
            {
                Console.WriteLine("Try again!");
            }
        }