본문 바로가기
언어/[C#]

[C#] 피타고라스 정리 (hypotenuse)

by 조랩 2023. 3. 1.
using System;

namespace MyFirstProgram
{
    internal class Program
    {

        static void Main(string[] args) // main method
        {
        
            // 피타고라스

            Console.WriteLine("Enter side A: ");
            double a = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter side B: ");
            double b = Convert.ToDouble(Console.ReadLine());

            double c = Math.Sqrt((a * a) + (b * b));
            Console.WriteLine("The hypotenuse is : " + c);

            Console.ReadKey();

        }
    }
}

 

Math클래스를 이용해 피타고라스의 정리 - 빗변 길이 구하기

728x90