三角形

来源:互联网 发布:淘宝好评如何删除评价 编辑:程序博客网 时间:2024/04/29 16:21
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _3jiao_xing{    class Program    {        static void Main(string[] args)        {            double a,b,c;  //边长            Console.WriteLine("输入边长a");            a=Convert.ToDouble(Console. ReadLine());            Console.WriteLine("输入边长b");            b=Convert.ToDouble(Console. ReadLine());            Console.WriteLine("输入边长c");            c=Convert.ToDouble(Console. ReadLine());            if (a<=0||b<=0||c<=0)  //防止输入错误数值            {                 Console.WriteLine("输入错误");            Console.Read();            }            if (a + b > c && a + c > b && b + c > a)  //判断是否为三角形            {                if (a == b && b == c)                {  Console.WriteLine("是等边三角形");                    Console.Read(); }                else if (a == b || b == c || a == c)                {  Console.WriteLine("是等腰三角形");                    Console.Read();  }                else if ((a * a) + (b * b) == (c * c) || (a * a) + (c * c) == (b * b) || (b * b) + (c * c) == (a * a))                {                    {                        Console.WriteLine("是直角三角形");                        Console.Read();                    }                    if (a == b || b == c || a == c)                    {                        Console.WriteLine("是等腰直角三角形");                        Console.Read();                    }                }                else                {                    Console.WriteLine("是任意三角形");                    Console.Read();                }            }            else            {                Console.WriteLine("输入的三边不能组成三角形");                Console.Read();            }        }    }}

0 0