コード例 #1
0
        //
        static void Loop()
        {
            bool       userWantsToExit = false;
            TextReader cin             = Console.In;
            TextWriter Out             = Console.Out;
            string     cad;

            //get input
            while (!userWantsToExit)
            {
                {
                    Out.Write('>');
                    cad = cin.ReadLine();
                }
                try
                {
                    Expression expr = new Expression(new TokenStream(cad.Trim()));
                    expr.Calculate();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                if (cad.ToUpper().Equals("exit".ToUpper()))
                {
                    userWantsToExit = true;
                }
            }
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string expression = this.expressionTextBox.Text;

            function = new Parser.Expression(expression);
            MessageBox.Show(function.Calculate(new System.Collections.Generic.List <double>()
            {
                0.0, 0.0
            }).ToString());
        }
コード例 #3
0
        static double y(double x)
        {
            List <double> variables = new List <double>();

            //сосчитываем аргументы

            /* Console.WriteLine();
             * for (int i = 0; i < func.variablesNum; i++)
             * {
             *   string d = Console.ReadLine();
             *   variables.Add(Double.Parse(d));
             * }*/

            variables.Add(x);
            return(func.Calculate(variables));
        }