Beispiel #1
0
        static void Main(string[] args)
        {
            ParserFunction.addFunction("pi", new PiFunction());
            ParserFunction.addFunction("exp", new ExpFunction());
            ParserFunction.addFunction("pow", new PowFunction());
            ParserFunction.addFunction("sin", new SinFunction());
            ParserFunction.addFunction("abs", new AbsFunction());
            ParserFunction.addFunction("sqrt", new SqrtFunction());

            calculate("(((-5.5)))", (((-5.5))));
            calculate("1-2", 1 - 2);
            calculate("(1-(2))", (1 - (2)));
            calculate("3+2*6-1", 3 + 2 * 6 - 1);
            calculate("3-2*6-1", 3 - 2 * 6 - 1);
            calculate("1-2-3-(4-(5-(6-7)))", 1 - 2 - 3 - (4 - (5 - (6 - 7))));
            calculate("2-3*sin(pi)", 2 - 3 * Math.Sin(Math.PI));
            calculate("1-(exp(10*7-sqrt((1+1)*20*10)))", 1 - (Math.Exp(10 * 7 - Math.Sqrt((1 + 1) * 20 * 10))));
            calculate("3-(5-6)-(2-(3-(1-2)))", 3 - (5 - 6) - (2 - (3 - (1 - 2))));
            calculate("3-(5-6)-(2-(3-(1+2)))+2-(-1+7)*(9-2)/((16-3)-3)+15/2*5",
                      3 - (5 - 6) - (2 - (3 - (1 + 2))) + 2 - (-1 + 7) * (9 - 2) / ((16.0 - 3) - 3.0) + 15 / 2.0 * 5);
            calculate("(-1+7)*(9-2)", (-1 + 7) * (9 - 2));
            calculate("((16-3)-3)+15/2*5", ((16 - 3) - 3) + 15 / 2.0 * 5);
            calculate("1+15/2*5", 1 + 15 / 2.0 * 5);
            calculate("3-2/6-1", 3 - 2 / 6.0 - 1);
            calculate("3*50-3*2^4*3", 3 * 50 - 3 * Math.Pow(2, 4) * 3);
            calculate("5-1/2^2-3", 5 - 1 / Math.Pow(2, 2) - 3);
            calculate("(((1/4/2-(8/2/3+5))))", (((1 / 4.0 / 2.0 - (8 / 2.0 / 3.0 + 5)))));
            calculate("pow(2,3)", Math.Pow(2, 3));
            calculate("abs(3*-50-2*3/4)/3*2", Math.Abs(3.0 * -50 - 2 * 3.0 / 4.0) / 3.0 * 2);

            Console.ReadKey();
        }