Exemplo n.º 1
0
        public static string GetAnswer(string input)
        {
            var strDet = MatrixDetSolver.GetAns(input);
            var det    = long.Parse(strDet);
            var m      = MatrixDetSolver.GetArrayFromTheString(input);

            if (det == 0)
            {
                return("unsolvable");
            }
            decimal[][] inv = MatrixInverse(m);

            var dimensionMatrix = inv.Length;
            var answer          = new StringBuilder();

            for (int i = 0; i < inv.Length; i++)
            {
                for (int j = 0; j < inv.Length; j++)
                {
                    if (j != dimensionMatrix - 1)
                    {
                        answer.Append(inv[i][j].ToString(CultureInfo.InvariantCulture) + " & ");
                    }
                    else if (dimensionMatrix - 1 != i)
                    {
                        answer.Append(inv[i][j].ToString(CultureInfo.InvariantCulture) + " \\\\ ");
                    }
                    else
                    {
                        answer.Append(inv[i][j].ToString(CultureInfo.InvariantCulture));
                    }
                }
            }
            return(answer.ToString());
        }
Exemplo n.º 2
0
 private string GetAns(string type, string task)
 {
     type = GetTypeOfTheTask(type);
     return(type switch
     {
         "math" => MathSolution.GetAns(task),
         "polynomial-root" => PolynomsSolver.GetRoot(task),
         "shape" => ShapeSolver.GetAns(task),
         "determinant" => MatrixDetSolver.GetAns(task),
         "cypher" => Caesar.GetAns(task),
         "string-number" => StringNumber.GetNumber(task),
         "starter" => "42",
         "inverse-matrix" => InverseMatrix.GetAnswer(task),
         _ => string.Empty
     });
Exemplo n.º 3
0
 private string GetAns(string type, string task)
 {
     type = GetTypeOfTheTask(type);
     return(type switch
     {
         "math" => MathSolution.GetAns(task),
         "polynomial-root" => PolynomsSolver.GetRoot(task),
         "shape" => ShapeSolver.GetAnswer(task),
         "determinant" => MatrixDetSolver.GetAns(task),
         "cypher" => Caesar.GetAns(task),
         "string-number" => StringNumber.StringToNumber(task),
         "starter" => "42",
         "json" => Json.GetAnswer(task),
         "inverse-matrix" => InverseMatrix.GetAnswer(task),
         _ => "Я не знаю тип задания, помогите"
     });
Exemplo n.º 4
0
        private string GetAns(string type, string task)
        {
            task = GetTypeOfTheTask(type);
            switch (type)
            {
            case "math": return(MathSolution.GetAns(task));

            case "polynomial-root": return(PolynomsSolver.GetRoot(task));

            case "shape": return(ShapeSolver.GetAns(task));

            case "determinant": return(MatrixDetSolver.GetAns(task));

            case "cypher": return(Caesar.GetAns(task));

            case "string-number": return(StringNumber.GetNumber(task));

            case "starter": return("42");

            default: return(string.Empty);
            }
        }
Exemplo n.º 5
0
        public static string GetAnswer(string input)
        {
            /*
             * input:
             * 40 & -8 \\ -100 & 20
             * answer:
             * unsolvable
             *
             *
             * стоит еще потестить когда нормальный ответ
             * //*/

            var strDet = MatrixDetSolver.GetAns(input);
            var det    = long.Parse(strDet);
            var a      = MatrixDetSolver.GetArrayFromTheString(input);

            if (det != 0)
            {
                return(TransposeMatrix(1.0M / det, a));
            }
            return("unsolvable");
            //*/
        }