예제 #1
0
파일: Form1.cs 프로젝트: IKaskov/Calculator
        private void buttonCulc_Click(object sender, EventArgs e)
        {
            t = labelPrim.Text;

            q.Add(t);

            label3.Text = string.Empty;

            labelPrim.Text = (RPN.CalculateRPN(q)).ToString();
            q.Clear();
        }
예제 #2
0
        static void Main(string[] args)
        {
            //BigNumber a = new BigNumber("4");
            //BigNumber b = new BigNumber("11");
            //Console.WriteLine(a % b);

            //BigPointNumber x = new BigPointNumber("4");
            //BigPointNumber y = new BigPointNumber("13");
            //Console.WriteLine(x / y);

            //Stopwatch stopwatch = Stopwatch.StartNew();
            //var res1 = BigPointNumber.Factorial(20000).ToString();
            //stopwatch.Stop();
            //var time = stopwatch.Elapsed;
            //Console.WriteLine($"{res1}  -  Len: {res1.Length}");
            //Console.WriteLine();

            Console.Write("Введите выражение: ");
            Console.WriteLine(RPN.Calculate(Console.ReadLine()));

            Console.ReadKey();
        }
예제 #3
0
        /*ВЫВОД РЕШЕНИЯ*/

        //Вывод решения на экран (используется обратная польская запись)
        private void btn_equal_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (check_output(TextOutput.Text))
                {
                    TextHistory.Text += TextOutput.Text + "=";
                    double result = Math.Round(RPN.Calculate(TextOutput.Text), 10);
                    TextOutput.Text   = Convert.ToString(result);
                    TextHistory.Text += TextOutput.Text + "\n";
                }
                //Удаляется лишний символ в конце выражения для вывода решения
                else if (TextOutput.Text.Length != 0)
                {
                    TextOutput.Text   = TextOutput.Text.Remove(TextOutput.Text.Length - 1);
                    TextHistory.Text += TextOutput.Text + "=";
                    double result = Math.Round(RPN.Calculate(TextOutput.Text), 10);
                    TextOutput.Text   = Convert.ToString(result);
                    TextHistory.Text += TextOutput.Text + "\n";
                }
            }
            catch (MyException ex) { TextOutput.Text = ex.type; }
        }
예제 #4
0
 /*РЕШЕНИЕ ВЫРАЖЕНИЯ + ВЫВОД*/
 private void btn_equal_Click(object sender, RoutedEventArgs e)
 {
     left = 0; right = 0;
     try
     {
         if (check_output(TextOutput.Text))
         {
             TextHistory.Text += TextOutput.Text + "=";
             double result = RPN.Calculate(TextOutput.Text);
             TextOutput.Text   = Convert.ToString(result);
             TextHistory.Text += TextOutput.Text + "\n";
         }
         else if (TextOutput.Text.Length != 0)
         {
             TextOutput.Text   = TextOutput.Text.Remove(TextOutput.Text.Length - 1);
             TextHistory.Text += TextOutput.Text + "=";
             double result = RPN.Calculate(TextOutput.Text);
             TextOutput.Text   = Convert.ToString(result);
             TextHistory.Text += TextOutput.Text + "\n";
         }
     }
     catch (MyException ex) { TextOutput.Text = ex.type; }
 }
예제 #5
0
 private void button17_Click(object sender, EventArgs e)
 {
     try { richTextBox2.Text = RPN.Calculate(richTextBox1.Text).ToString(); }
     catch (MyException ex) { richTextBox2.Text = ex.type; }
 }
예제 #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     label1.Text = RPN.Calculate(textBox1.Text).ToString();
 }