Advertisement
Fanta-MindTerror

isTriangle

Dec 24th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             while (true)
  6.             {
  7.                 Console.WriteLine("Введите 1 сторону");
  8.                 int a = Convert.ToInt32(Console.ReadLine());
  9.                 Console.WriteLine("Введите 2 сторону");
  10.                 int b = Convert.ToInt32(Console.ReadLine());
  11.                 Console.WriteLine("Введите 3 сторону");
  12.                 int c = Convert.ToInt32(Console.ReadLine());
  13.                 Console.WriteLine("Результат " + isTriangle(a,b,c));
  14.             }
  15.         }
  16.  
  17.         static bool isTriangle(int a,int b, int c)
  18.         {
  19.             if( a <= 0 || b <= 0 || c <= 0)
  20.             {
  21.                 return false;
  22.             }
  23.             if ( a + b > c && a + c > b && b + c > a)
  24.             {
  25.                 return true;
  26.             }
  27.             else
  28.             {
  29.                 return false;
  30.             }
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement