Advertisement
Sim0o0na

Untitled

Jun 12th, 2017
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication3
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             int a = int.Parse(Console.ReadLine());
  16.             int b = int.Parse(Console.ReadLine());
  17.             int c = int.Parse(Console.ReadLine());
  18.  
  19.  
  20.             int valid = 0;
  21.             
  22.  
  23.           
  24.  
  25.  
  26.             if ((a + b) > c)
  27.             {
  28.                 if ((b + c) > a)
  29.                 {
  30.                     if ((a + c) > b) //If a+b>c and a+c>b and b+c>a then it is valid  
  31.                     {
  32.                         valid = 1;
  33.                     }
  34.                 }
  35.             }
  36.  
  37.             if (valid == 1)
  38.             {
  39.                 Console.WriteLine("Triangle is valid.\n");
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("Invalid Triangle.");
  44.             }
  45.  
  46.  
  47.             if (a*a + b*b == c*c)
  48.             {
  49.                 Console.WriteLine("Triangle has a right angle between sides a and b");
  50.             }
  51.             else if (b*b + c*c == a*a)
  52.             {
  53.                 Console.WriteLine("Triangle has a right angle between sides b and c");
  54.             }
  55.             else if (c*c + a*a == b*b)
  56.             {
  57.                 Console.WriteLine("Triangle has a right angle between sides a and c");
  58.             }
  59.             else
  60.             {
  61.                 Console.WriteLine("Triangle has no right angles");
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement