Cassimus

Trójkąt

Sep 26th, 2025 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. internal class Program
  2. {
  3.     private static void Main(string[] args)
  4.     {
  5.         // pobranie długości boków
  6.         int bokA, bokB, bokC;
  7.         System.Console.WriteLine("Podaj długość pierwszego boku");
  8.         bokA = int.Parse(Console.ReadLine());
  9.  
  10.         System.Console.WriteLine("Podaj długość drugiego boku");
  11.         bokB = int.Parse(Console.ReadLine());
  12.  
  13.         System.Console.WriteLine("Podaj długość trzeciego boku");
  14.         bokC = int.Parse(Console.ReadLine());
  15.  
  16.         // jeżeli suma każdy dwóch boków jest większa bądź
  17.         // równa dlugości trzeciego boku to jest to trójkąt
  18.  
  19.         bool czyTrojkat = bokA + bokB > bokC
  20.             && bokB + bokC > bokA
  21.             && bokC + bokA > bokB;
  22.  
  23.         if (czyTrojkat)
  24.         {
  25.             System.Console.WriteLine("To jest trojkąt");
  26.         }
  27.  
  28.         if (bokA == bokB && bokB == bokC)
  29.         {
  30.             System.Console.WriteLine("To jest trójkąt równoboczny");
  31.         }
  32.  
  33.         if (bokA == bokB || bokB == bokC || bokC == bokA)
  34.         {
  35.             System.Console.WriteLine("Trójkąt jest równoramienny");
  36.         }
  37.  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment