判定三角形

来源:互联网 发布:自学虚幻4还是unity3d 编辑:程序博客网 时间:2024/05/16 23:40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication10
{
    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();
        }

0 0