Advertisement
tothl

Pitagorasz

Sep 30th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Pitagorasz
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int a,b;
  10.             double c;
  11.            
  12.             Console.Clear();
  13.             Console.WriteLine("Pitagorasz tétel?\n---------------------------------\n");
  14.            
  15.             Console.Write("Kérem az A oldalt: ");
  16.             a = int.Parse(Console.ReadLine());
  17.            
  18.             Console.Write("Kérem az B oldalt: ");
  19.             b = int.Parse(Console.ReadLine());
  20.            
  21.             if (a<1 || b<1) Console.WriteLine("Negatív számot adtál meg!");
  22.             else{
  23.                 c=a*a+b*b;
  24.                 c= Math.Sqrt(c);
  25.                 Console.WriteLine("A C oldal hossza: {0}",c);
  26.             }
  27.            
  28.             Console.ReadLine();
  29.            
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement