本文介绍了计算器输出C锐利的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在做一个计算器,我需要以这种方式显示计算器的输出,例如:1 + 1 = 2 + 2 = 4

是否可以?



Hello I am doing a calculator and I need to show the output of the calculator in this way for example: 1+1=2+2=4
Is it possible ?

if (operator == "+")
           {
               double a = 0;
               string[] chaine = textBox1.Text.Split('+');
               textBox1.Text += Environment.NewLine + "=" + Environment.NewLine + (double.Parse(chaine[0]) + double.Parse(chaine[1])).ToString(); //first choice of the operation

               for (int i = 0; i < chaine.Length; i++)
               {
                   a += double.Parse(chaine[i]);

               }

               textBox1.Text = a.ToString();//second choice of the operation





我的尝试:



我可以做的是这样的1 + 1,它给出结果2



What I have tried:

What I can do it is something like this 1+1 and it give the result 2

推荐答案


// Before operator check
public void operator_Click (object sender, EventArgs e) {
    if(resultAvailable) {
        // Change the values
        a = result;
    }
    op = operatorTxt.Text;
}

// In the resolution function
public void evaluate(object sender, EventArgs e) {
   // Evaluate the answer in result variable for further use.
}



这样,您就可以在解析之前的表达式后处理它们。这就是现代移动计算器所做的工作。


This way, you will be able to process the expressions after resolving the previous ones. That is what is done in the modern mobile calculators.


这篇关于计算器输出C锐利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 06:33