c#弄了简单计算器,想问如何多次运算.
c#弄了简单计算器,想问如何多次运算.
double a, b;
double flag;
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "0";
}
private void button11_Click(object sender, EventArgs e)
{
b = Convert.ToDouble(textBox1.Text);
if (flag == 1)
textBox1.Text = Convert.ToString(a + b);
if (flag == 2)
textBox1.Text = Convert.ToString(a - b);
if (flag == 3)
textBox1.Text = Convert.ToString(a * b);
if (flag == 4)
textBox1.Text = Convert.ToString(a / b);
}
private void button12_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
private void button13_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
flag = 4;
textBox1.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "1";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "2";
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "3";
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "4";
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "5";
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "6";
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "7";
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "8";
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "9";
}
private void button16_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
flag = 1;
textBox1.Text = "";
}
private void button15_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
flag = 2;
textBox1.Text = "";
}
private void button14_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(textBox1.Text);
flag = 3;
textBox1.Text = "";
(a+b)*c 这样的?+ - * / ( )有个优先级表,然后判断输出优先级