编程求三角形

来源:互联网 发布:linux系统版本选择 编辑:程序博客网 时间:2024/06/02 07:30
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            Console.WriteLine("请输入第一条边");            int x = Convert.ToInt32(Console.ReadLine());            Console.WriteLine("请输入第二条边");            int b = Convert.ToInt32(Console.ReadLine());            Console.WriteLine("请输入第三条边");            int g = Convert.ToInt32(Console.ReadLine());            Triangle t = new Triangle();            t.Func(x, b, g);        }    }    class Triangle    {        public void Func(int b1, int b2, int b3)        {            if (b1 + b2 > b3 && b1 + b3 > b2 && b2 + b3 > b1)            {                Console.WriteLine("就可以组成三角形");                if (b1 == b2 && b2 == b3)                    Console.WriteLine("就是等边三角形");                else                    if (b1 == b2 || b2 == b3 || b1 == b3)                        Console.WriteLine("就是等腰三角形");            }            else                Console.WriteLine("输入的三边不可能组成三角形");            Console.Read();        }    }}

 

总结:通过这次学习.我知道了如何编程求三角形。

0 0