输入三条边判断三角形

来源:互联网 发布:linux shell替换字符串 编辑:程序博客网 时间:2024/04/30 02:03
软件技术1班      作    者:A29 邢晓康  完成日期:2014年 10 月 25 日      问题描述:根据输入的三条边判断三角形using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 三角形{    class Program    {        static void Main(string[] args)        {            Console.WriteLine("请输入第一条边");            int a = Convert.ToInt32(Console.ReadLine());            Console.WriteLine("请输入第二条边");            int b = Convert.ToInt32(Console.ReadLine());            Console.WriteLine("请输入第三条边");            int c = Convert.ToInt32(Console.ReadLine());            Triangle t = new Triangle();            t.Func(a, b, c);        }    }    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();        }    }}  


总结:通过这次练习,我略略地了解了如何通过C#语言中的IF语句编写此类程序,感觉受益颇深。

0 0
原创粉丝点击