3个数求最大值和最小值 纠错
public partial class Form1 : Form{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int x, y, z,max;
x = int.Parse(textBox1.Text);
y = int.Parse(textBox2.Text);
z = int.Parse(textBox3.Text);
if(x>y)
{
if(y>z)
if(x>z)
{
max=x;
z=y;
}
else
{
x=z;
z=y;
}
if(x>z)
{
x=y;
}
else if(y>z)
{
z = x;
max=y;
x = max;
}
else
{
max=z;
z=x;
x = max;
}
}
label1.Text = "最大值为:" + x+ "最小值为:" + z;
}
}
}
求正确的祥解!!!