题解 | #三角形判断#
三角形判断
https://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
public class Program { public static void Main() { string line; while ((line = System.Console.ReadLine()) != null) { string[] nums = line.Split(" "); int x = int.Parse(nums[0]); int y = int.Parse(nums[1]); int z = int.Parse(nums[2]); //任意两边之和大于第三边则能构成三角形 if (x + y > z && x + z > y && y + z > x) { //等边三角形 if (x == y && x == z) System.Console.WriteLine("Equilateral triangle!"); //等腰三角形 else if (x == y || x == z || y == z) System.Console.WriteLine("Isosceles triangle!"); else System.Console.WriteLine("Ordinary triangle!"); } else System.Console.WriteLine("Not a triangle!"); } } }