菜鳥的入門(一)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace 三角形
{
    class Program
    {
        static void Main(string[] args)
        {
           
            //輸入三角形三遍的的長
            Console.WriteLine("三角形三邊長爲a,b,c");
            string abcIn = Console.ReadLine();
            string[] abc = abcIn.Split(' ');
            double a = Convert.ToDouble(abc[0]);
            double b = Convert.ToDouble(abc[1]);
            double c = Convert.ToDouble(abc[2]);
            if (a + b > c && a + c > b && b + c > a)
            {
                //能夠成三角形
                double s = (a + b + c) / 2;
                double area = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
                Console.WriteLine("三角形面積爲{0}", area);


            }
            else 
             {
                 Console.WriteLine("不能夠成三角形");
              }
            Console.Read();
        }
    }
}
發佈了7 篇原創文章 · 獲贊 1 · 訪問量 5993
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章