编写C#程序,输入三角形的三边,判断其组成三角形的情形(等边,等腰,直角,任意三角形) 30
2个回答
展开全部
public string Fuation(Decimal a, Decimal b, Decimal c)
{
Decimal MaxNum = 0;
Decimal MinNuma = 0;
Decimal MinNumb = 0;
if (a > b && a > c)
{
MaxNum = a;
MinNuma = b;
MinNumb = c;
}
else if (b > a && b > c)
{
MaxNum = b;
MinNuma = a;
MinNumb = c;
}
else
{
MaxNum = c;
MinNuma = a;
MinNumb = b;
}
if (a == b && a == c && b == c)
{
return "等边三角形";
}
else if (a == b || a == c || b == c)
{
return "等腰三角形";
}
else
{
if (MaxNum * MaxNum == MinNuma * MinNuma + MinNumb * MinNumb)
{
return "直角三角形";
}
else
{
return "任意三角形";
}
}
}
引用, TextBox1.Text = Fuation(5, 4, 3);
{
Decimal MaxNum = 0;
Decimal MinNuma = 0;
Decimal MinNumb = 0;
if (a > b && a > c)
{
MaxNum = a;
MinNuma = b;
MinNumb = c;
}
else if (b > a && b > c)
{
MaxNum = b;
MinNuma = a;
MinNumb = c;
}
else
{
MaxNum = c;
MinNuma = a;
MinNumb = b;
}
if (a == b && a == c && b == c)
{
return "等边三角形";
}
else if (a == b || a == c || b == c)
{
return "等腰三角形";
}
else
{
if (MaxNum * MaxNum == MinNuma * MinNuma + MinNumb * MinNumb)
{
return "直角三角形";
}
else
{
return "任意三角形";
}
}
}
引用, TextBox1.Text = Fuation(5, 4, 3);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询