public MyNumber OneStepCalculate(MyNumber num1, MyNumber num2, int opera)
 {
     if (opera == 101)
     {
         return(num1 + num2);
     }
     else if (opera == 102)
     {
         return(num1 - num2);
     }
     else if (opera == 103)
     {
         return(num1 * num2);
     }
     else if (opera == 104)
     {
         return(num1 / num2);
     }
     else if (opera == 105)
     {
         return(num1 ^ num2);
     }
     else
     {
         MyNumber error = new MyNumber(-1);
         return(error);
     }
 }
        /*要求用户输入答案并与结果比较*/
        public int GetResult(MyNumber res, string yourans)
        {
            int formflag = CheckYourAnswer(yourans);        //判断答案格式是否正确

            if (formflag == 1)
            {
                //sign代表答案符号,ansnum[0]为分子,[1]为分母
                int[] ansnum = new int[] { 0, 1 };
                int   sign   = TurnToNumber(yourans, ansnum);
                if (ansnum[1] != 0)                         //判断分母是否为0
                {
                    MyNumber yourres = new MyNumber(ansnum[0], ansnum[1], sign);
                    if (yourres == res)
                    {
                        return(1);
                    }
                    //cout << "Right" << endl;
                    else
                    {
                        return(0);
                    }
                    //cout << "Wrong" << endl;
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(3);
            }
        }
 public NumNode(MyNumber value)
 {
     this.type = 1;
     this.value = value;
     this.left = null;
     this.right = null;
 }
        public static MyNumber operator +(MyNumber a, MyNumber b)
        {
            MyNumber c = new MyNumber();

            c.numerator   = a.numerator * b.denominator + a.denominator * b.numerator;
            c.denominator = a.denominator * b.denominator;
            return(c);
        }
        public static MyNumber operator *(MyNumber a, MyNumber b)
        {
            MyNumber c = new MyNumber
            {
                numerator   = a.numerator * b.numerator,
                denominator = a.denominator * b.denominator
            };

            return(c);
        }
        public static MyNumber operator ^(MyNumber a, MyNumber b)
        {
            MyNumber c = new MyNumber(1);

            for (int i = 0; i < b.numerator; i++)
            {
                c = c * a;
            }
            return(c);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (ansText.Text == "")
            {
                ansText.Focus();
                return;
            }
            Ans ans = new Ans();

            TreeList[onequestion].getroot().value.Reduction();//对分子分母进行化简

            MyNumber correctAnswer    = TreeList[onequestion].getroot().value;
            int      ansflag          = ans.GetResult(correctAnswer, this.ansText.Text);
            string   correctAnswerStr = correctAnswer.M_ToString();

            if (ansflag == 1)
            {
                timer1.Stop();
                MessageBox.Show("回答正确\n");
                timer1.Start();
                score++;
                scoreText.Text = "得分:" + score.ToString();

                this.ansText.Text = "";
                totalTime         = 20;
            }
            else if (ansflag == 0)
            {
                timer1.Stop();
                MessageBox.Show("回答错误\n" + "正确答案是:" + correctAnswerStr);
                timer1.Start();
                chance = chance - 1;
                if (chance <= 0)
                {
                    re.Visible        = true;
                    record.Visible    = true;
                    ansText.Visible   = false;
                    button2.Visible   = false;
                    timerText.Visible = false;
                    scoreText.Visible = false;
                    hp.Visible        = false;
                    history.Visible   = false;
                    label1.Visible    = false;
                    timer1.Stop();
                    reto.Visible = false;

                    MessageBox.Show("很遗憾,您的错误次数过多\n请点击确定查看您的答题情况");
                    MessageBox.Show("您一共答对" + score + "道题,答错10道题\n请继续加油喔");

                    Application.Exit();
                }
                hp.Text = "剩余机会:" + chance.ToString();

                this.ansText.Text = "";
                totalTime         = 20;
            }
            else
            {
                timer1.Stop();
                MessageBox.Show("请输入正确的答案格式");
                timer1.Start();
                this.ansText.Text = "";
                this.ansText.Focus();
            }

            record.Text += StrList[onequestion] + "=" + correctAnswerStr + "\r\n";
            onequestion++;//题目加1
            button1_Click(null, null);
        }