using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 计算机12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string str, opp, opp1,x;
private void button13_Click(object sender, EventArgs e)
{
Button b = (Button)(sender);
if (b.Text == "+")
{
num1 = double.Parse(txtOutput.Text);
txtOutput.Text = "";
opp = "+";
opp1 = "";
}
else if (b.Text == "-")
{
num1 = double.Parse(txtOutput.Text);
txtOutput.Text = "";
opp = "-";
opp1 = "";
}
else if (b.Text == "*")
{
num1 = double.Parse(txtOutput.Text);
txtOutput.Text = "";
opp = "*";
opp1 = "";
}
else if (b.Text == "/")
{
num1 = double.Parse(txtOutput.Text);
txtOutput.Text = "";
opp = "/";
opp1 = "";
}
else if (b.Text == "=")
{
if (opp1 != "=")
{
num2 = double.Parse(txtOutput.Text);
}
if (opp == "+")
{
num3 = num1 + num2;
txtOutput.Text = "" + num3.ToString();
}
else if (opp == "-")
{
num3 = num1 - num2;
txtOutput.Text = "" + num3.ToString();
}
else if (opp == "*")
{
num3 = num1 * num2;
txtOutput.Text = "" + num3.ToString();
}
else if (opp == "/")
{
if (num2 == 0)
{
txtOutput.Text = "除数不能为零";
}
else
{
num3 = num1 / num2;
txtOutput.Text=""+num3.ToString();
}
}
opp1 = "=";
x += num1 + opp + num2 + "=" + num3 + "\r\n";
textBox1.Text = x;
}
}
private void button10_Click(object sender, EventArgs e)
{
Button b = (Button)(sender);
if (b.Text == ".")
{
str = txtOutput.Text;
int index = str.IndexOf(".");
if (index == -1)
{
txtOutput.Text = str + ".";
}
}
else if (b.Text == "退格")
{
if (txtOutput.Text != "")
{
str = txtOutput.Text;
str = str.Substring(0, str.Length - 1);
txtOutput.Text = str;
}
}
else if (b.Text == "CE")
{
txtOutput.Text = "0";
}
else if (b.Text == "C")
{
result = num1 = num2 = 0;
str = null;
opp = null;
txtOutput.Text = "0";
x = "";
textBox1.Text = x;
}
opp = "";
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
double num1, num2,num3,result;
private void button1_Click(object sender, EventArgs e)
{
Button b = (Button)(sender);
str = b.Text;
if (txtOutput.Text == "0")
{
txtOutput.Text = str;
}
else
txtOutput.Text = txtOutput.Text + str;
}
}
}