Advertisement
Guest User

Triangle Formations

a guest
Apr 8th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09_Triangle_Formations
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int a = int.Parse(Console.ReadLine());
  14.             int b = int.Parse(Console.ReadLine());
  15.             int c = int.Parse(Console.ReadLine());
  16.  
  17.             if (a + b >= c && a + c >= b && b + c >= a)
  18.             {
  19.                 Console.WriteLine("Triangle is valid.");
  20.                 if (a == b && b == c && c == a)
  21.                 {
  22.                     Console.WriteLine("Triangle has no right angles");
  23.                 }
  24.                 else if (Math.Pow(a, 2) + Math.Pow(b, 2) == Math.Pow(c, 2))
  25.                 {
  26.                     Console.WriteLine("Triangle has a right angle between sides a and b");
  27.                 }
  28.                 else if (Math.Pow(b, 2) + Math.Pow(c, 2) == Math.Pow(a, 2))
  29.                 {
  30.                     Console.WriteLine("Triangle has a right angle between sides b and c");
  31.                 }
  32.                 else if (Math.Pow(a, 2) + Math.Pow(c, 2) == Math.Pow(b, 2))
  33.                 {
  34.                     Console.WriteLine("Triangle has a right angle between sides a and c");
  35.                 }
  36.             }
  37.             else
  38.             {
  39.                 Console.WriteLine("Invalid Triangle.");
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement