//完成时间:11月3日
//问题描述:输入三角形的三条边a,b,c的值,根据其数值,判断能否构成三角形;若能,还要显示三角形的性质:等边三角形、等腰三角形、直角三角形和任意三角形。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication34
{
class Program
{
static void Main(string[] args)
{
double a = 0, b = 0, c = 0;
string result = "";
Console.WriteLine("请输入三条边的边长,以回车为间隔");
a = double.Parse(Console.ReadLine());
b = double.Parse(Console.ReadLine());
c = double.Parse(Console.ReadLine());
if (a + b > c && a + c > b && b + c > a)
{
if (a == b && b == c) result = "等边";
else if (a == b || a == c || b == c)
{
result = "等腰";
if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) result += "直角";
}
else if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) result = "直角";
else result = "任意";
}
else result = "非";
Console.Clear();
Console.WriteLine("边长为{0},{1},{2}的三条边构成\n{3}三角形", a, b, c, result);
Console.ReadLine();
}
}
//问题描述:输入三角形的三条边a,b,c的值,根据其数值,判断能否构成三角形;若能,还要显示三角形的性质:等边三角形、等腰三角形、直角三角形和任意三角形。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication34
{
class Program
{
static void Main(string[] args)
{
double a = 0, b = 0, c = 0;
string result = "";
Console.WriteLine("请输入三条边的边长,以回车为间隔");
a = double.Parse(Console.ReadLine());
b = double.Parse(Console.ReadLine());
c = double.Parse(Console.ReadLine());
if (a + b > c && a + c > b && b + c > a)
{
if (a == b && b == c) result = "等边";
else if (a == b || a == c || b == c)
{
result = "等腰";
if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) result += "直角";
}
else if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) result = "直角";
else result = "任意";
}
else result = "非";
Console.Clear();
Console.WriteLine("边长为{0},{1},{2}的三条边构成\n{3}三角形", a, b, c, result);
Console.ReadLine();
}
}
}