Exemple #1
0
 private void button18_Click(object sender, EventArgs e)
 {//'='
     if (leBrac == true || biOpe == true || lastStr.Count == 0)
     {
     }
     else
     {
         int n_left = 0, n_right = 0;    //已经输入的左右括号个数
         foreach (String i in lastStr)
         {
             if (i == ",(,")
             {
                 n_left++;
             }
             if (i == ",),")
             {
                 n_right++;
             }
         }
         if (n_left != n_right)
         {
         }                           //左右括号数不配对则不能开始计算
         else
         {
             Calculate calculate = new Calculate();
             Pair      answer    = calculate.Run(lastStr);
             if (answer.flag == false)
             {
                 textBox1.Text = "Error";
             }
             else
             {
                 textBox2.Text = textBox1.Text;
                 textBox1.Text = Convert.ToString(answer.answer);
             }
             SetBool();
             lastStr.Clear();
             haveDot   = false;
             beginning = true;
         }
     }
 }