이 페이지는 코딩도장 데이터의 읽기 전용 정적 보관본입니다.

대각선 길이 구하기

직각삼각형의 밑변이 x, 높이가 y일 때 남은 변(대각선)의 길이를 구하는 함수를 만들어주세요.

ps. 요즘 대각선계산기 어플이 인기가 있는 걸 보고 한번 직접 만들어보는 것도 좋다고 생각해서 문제를 만들어 올립니다.

2019/08/25 19:13

ChoiGoBin

131개의 풀이가 있습니다.

def diagonal():
    x=float(input())
    y=float(input())
    result=(x**2+y**2)**0.5
    print(result)

diagonal()

2019/08/25 19:19

ChoiGoBin

Python 3.7

x, y = list(map(int, input().split(' ')))
print((x**2 + y**2)**0.5)

Input

3 4

Output

5.0

2019/08/26 17:16

AY

1

public static void main(String[] args) {
    Scanner scn=new Scanner(System.in);

    System.out.println("수를 입력하시요");
    int x=scn.nextInt();
    int y=scn.nextInt();

    int a=(x*x)+(y*y);
    double A=Math.sqrt(a);

    System.out.print("대각선의 길이는 "+A);
}

왕초보에용

2019/08/27 23:58

흐에엥

파이썬 3.8.10으로 작성했습니다.

import math
x, y = map(int, input().split())
print(math.sqrt(x**2 + y**2))

2021/07/28 16:44

baek choi

hypo = lambda x, y:(x**2+y**2)**0.5

2019/08/26 10:54

돔돔

def func():
    x = int(input())
    y = int(input())
    a = (x**2 + y**2)**0.5
    return a

2019/08/26 20:39

ff wq

x,y = map(int ,input("x,y를 순서대로 입력하세요: ").split())
print("대각선의 길이는: ",(x**2 + y**2)**0.5)

2019/08/27 14:43

김상호

const computeLength = (x, y) => (x**2 + y**2)**0.5;

2019/08/28 22:14

Creator

public class coding { public double aa(int x, int y) { return Math.sqrt(x*x + y*y); }

public static void main(String[] args) {
    coding c = new coding();
    System.out.println(c.aa(4, 7));

}
}

반성하겠습니다.

2019/08/29 14:37

우태균

한 줄로 줄일 수 있을까요

base, arc = map(float, input(). split(' '))
print(math.sqrt(base*base + arc*arc))

2019/09/01 16:05

ㅇㅈㅎ

import math

x= int(input("x=")) y= int(input("y="))

a = math.sqrt(x2+y2) print(a)

2019/09/02 15:43

홍재빈

        static void Main(string[] args)
        {
            Console.Write("높이 : ");
            int Height = Convert.ToInt32(Console.ReadLine());

            Console.Write("밑변 : ");
            int Base = Convert.ToInt32(Console.ReadLine());

            double Result = Math.Sqrt(Math.Pow(Height, 2) + Math.Pow(Base, 2));

            Console.WriteLine(Result);
        }

2019/09/02 15:45

김저승

from math import sqrt

x, y = input("밑변과 높이를 입력하시오").split()
x, y = int(x), int(y)

diagonal = sqrt(x*x + y*y)

print('대각선의 길이는 %.2f' %diagonal)

2019/09/03 20:32

농창

import java.util.; import java.lang.; import java.io.; import java.math.;

/ Name of the class has to be "Main" only if the class is public. /

class Ideone {

public static void main (String[] args) throws java.lang.Exception
{
    Scanner scanner=new Scanner(System.in);

    double a = Math.pow(scanner.nextInt(), 2);
    double b = Math.pow(scanner.nextInt(), 2);
    double d = Math.sqrt(a+b);

    System.out.println(d);

}

}

2019/09/03 23:19

nohanwoo no

include

include

float RightAngledTriangle(float a, float b) { float c = sqrt(a*a + b * b); return c; }

void main() { float c = RightAngledTriangle(3, 4); printf("%f", c); }

2019/09/04 09:29

ANG JAE

sqrt((x^2)+(y^2))

2019/09/04 10:28

Sola Hong

import java.util.Scanner;

public class RightTriangle { public static void main(String args[]) { int adjacent, height; Scanner sc = new Scanner(System.in); System.out.println("length of adjacent"); adjacent= sc.nextInt(); System.out.println("length of height"); height = sc.nextInt(); double squareaddresult = Math.pow(adjacent, 2)+ Math.pow(height, 2); double result = Math.sqrt(squareaddresult); System.out.println("the length of hypo:"+result); }

}


2019/09/04 12:23

Gene Kim

a,b=map(int,input().split()) a=a2 b=b2 c=a+b c=c**(1/2) print(c)

2019/09/04 17:46

김민성

C#

static double GetDiagonalLength(double x, double y) => Math.Sqrt(Math.Pow(x, 2.0) + Math.Pow(y, 2.0));

2019/09/10 18:02

mohenjo

PHP

$x = 3;
$y = 4;
$result = sqrt($x**2 + $y**2);
print_r($result); // 5

2019/09/11 09:34

d124412

print((input()**2+input()**2)**0.5)

파이썬한지 2년된 초보개발자 입니다~~

2019/09/20 08:23

코딩습관

def tri_side(x, y):
    side = ((x) ** 2 + y ** 2) ** 0.5
    print(side)

2019/09/22 14:59

박주현

#include<stdio.h>
#include<math.h>



int main(void)
{
    double x; //직각 삼각형의 밑변
    double y; //직각 삼각형의 높이
    double result; //대각선의 길이

    printf("x의 값을 기입하시오.");
    scanf("%lf", &x);

    printf("Y의 값을 기입하시오.");
    scanf("%lf", &y);

    result = sqrt(pow(x,2) + pow(y,2));
    printf("밑변의 길이 %.2f\n", x);
    printf("높이의 길이 %.2f\n", y);
    printf("대각선의 길이는 %.2f 입니다.\n", result);
    return 0;
}

C함수의 math.h라이브러리를 사용하여 제작한 함수 입니다.

2019/09/23 10:23

Ecarose

x = input("x :")
y = input("y :")
print("길이 :",  (int(x)**2+int(y)**2)**0.5)   #길이 계산

결과

x :5 y :9 길이 : 10.295630140987

2019/09/24 11:32

GG

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int x = scanner.nextInt();
    int y = scanner.nextInt();
    scanner.close();

    System.out.println(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
}

2019/09/24 16:12

이규정

while(True):
    choose=int(input("계속하시려면 1을 그만두시려면 2를 눌러 주세요: "))
    if choose==1:
        x=int(input("밑변를 입력해 주세요: "))
        y=int(input("높이를 입력해 주세요: "))        
        result=(x**2+y**2)**0.5
        print("결과는",result,"입니다")
    else:
        break

2019/09/25 10:30

조재용

x, y = map(int, input("Write X and Y with space").split(' ')); print("대각선의 길이:{}".format(float((x**2)+(y**2))**0.5))

2019/09/27 16:40

이명운

include

include

int main(void) { int x, y = 0; int z; printf("밑변과 높이를 입력하시오:"); scanf("%d %d", &x, &y); z = (xx + y * y);/루트를 씌울줄 몰라요*/ printf("남은 변의 길이는 %d입니다.", z); return 0; }

2019/09/30 17:13

이경수

def cal_tri(x, y):
    return (x**2 + y**2)**(1/2)

2019/10/14 01:47

심정현

import math
f=lambda x,y : math.sqrt(x**2+y**2)
print(f(2,3))

2019/10/18 23:51

semipooh

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Pythagoras(3, 4);
        }

        static void Pythagoras(int a, int b) // 대각선의 길이를 구하는 메소드
        {
            Console.WriteLine(Math.Sqrt(a * a + b * b));
        }
    }
}

2019/10/22 20:16

bat

x=input('Enter length: ')
y=input('Enter height: ')

X=float(x)
Y=float(y)

diagonal=X**2+Y**2

print('Diagonal:',diagonal**(1/2))

2019/10/27 00:39

생선집알바

x=int(input("밑변의 길이:"))
y=int(input("높이의 길이:"))
if x>0 and y>0:
    num=(x**2+y**2)**0.5
    print("diagonal=%s" %num)

2019/10/27 17:26

정윤지

#include <iostream>
#include <math.h>

using namespace std;

class Pythagoras{
private:
    int scroll;
    int height;
public:
    Pythagoras(int scroll, int height){this->height = height; this->scroll= scroll; }
    void show() { cout << "대각선의 길이 : " << sqrt(pow(scroll,2) + pow(height,2)) << endl; }
};

int main(){
    Pythagoras a =  Pythagoras(3,4);
    a.show();
}

C++ 입니다. 처음 올려보는 거라 조잡합니다.

2019/10/29 17:38

고창희

Common Lisp

(defun foo(x y)
  (sqrt(+(* x x)(* y y))))

2019/11/01 14:54

리스프

def length(x,y):
    return(x**2+y**2)

print(length(3,4))

결과가 도출되면 직접 루트를 씌워 주십시오. 코드가 간단한 대신 수동적인 느낌을 살려봤습니다.

2019/11/01 18:22

박지훈

import java.util.*;
public class 대각선길이구하기 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        System.out.println((int)Math.sqrt(x*x + y*y));
    }
}

2019/11/14 19:56

big Ko

def diag():
    a=float(input())
    b=float(input())
    c_sq=a**2 + b**2
    print(c_sq**0.5)

diag()

2019/11/17 12:58

CGC JunhanPark

import math

def sol(a, b): len_line = math.sqrt(pow(a, 2) + pow(b, 2)) return len_line print(sol(3,4)

2019/11/17 17:08

eju2003

x,y = map(int,input().split())
print(abs(x^2+y^2))

2019/11/20 23:29

photoshop428

x = input('밑변 입력 : ')
y = input('높이 입력 : ')

z = ((float(x) ** 2) + (float(y) ** 2)) ** (1/2)

print('대각선의 길이는 %f 입니다.' % float(z))

Python 작성

2019/11/25 15:13

DrKilling

include

include

void main() { double x, y, diagonal; printf("x = "); scanf_s("%f",&x); printf("y = "); scanf_s("%f", &y);

diagonal = sqrt(x*x + y * y);
printf("diagonal = %f", diagonal);

}

2019/11/27 14:16

ANG JAE

package diagonal;
import java.util.Scanner;
public class diagonal {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("Input the width and height:");
        int w=sc.nextInt();
        int h=sc.nextInt();
        double d=Math.sqrt(w*w + h*h);
        System.out.println("The diagonal:"+d);
    }
}

2019/12/03 21:52

Katherine

완전 초보에요. 하나하나 따라가보며 연습하려구요~

def diagonal():
    a=int(input('가로 길이를 입력하세요'))
    b=int(input('세로 길이를 입력하세요'))
    answer=(a**2+b**2)**0.5
    return answer

2019/12/10 00:03

김동석

x=int(input('x값을 입력하세요!'))
y=int(input('y값을 입력하세요!'))
ans=int(x**2+y**2)
print(ans**0.5)

2019/12/15 05:43

마요네즈[효우]

include

int main(void) { int x; std::cout <<"밑변의 길이를 입력하세요 : "; std::cin >> x;

int y;
std::cout << "높이를 입력하세요 : ";
std::cin >> y;

int result = sqrt(pow(x, 2) + pow(y, 2));
std::cout << "대각선 길이 : " << result << std::endl;

return 0;

}

2019/12/17 13:37

샬랄라왕자

파이썬3입니다.

def diag(x,y):
  return (x**2 + y**x) **0.5

2019/12/21 00:01

Sean

float diagonal(float a,b)
{
float result =0.0;
result = sqrt(a*a + b*b);

return result;
}

2019/12/23 21:12

Anderson

파이썬

import math
d=lambda x,y:math.sqrt(x^2+y^2)
# d(3,4) = 5^(1/2)

2019/12/24 17:25

data big

x1=float(input("밑변의 길이를 입력하십시오: "))
y1=float(input("높이를 입력하십시오: "))

def Hcal(x,y):
    x=x1
    y=y1
    z2=(x**2)+(y**2)
    z=float(pow(z2,(1/2)))
    return z

print("빗변의 길이는 "+str(Hcal(x1,y1))+"입니다.")

2019/12/25 23:13

박시원

import math
x=int(input())
y=int(input())

c=(x**2)+(y**2)
print(math.sqrt(c))

2019/12/26 14:26

뚜루꾸까까

public static void main(String[] args) { Scanner scn=new Scanner(System.in);

System.out.println("수를 입력하시요");
int x=scn.nextInt();
int y=scn.nextInt();

int a=(x*x)+(y*y);
double A=Math.sqrt(a);

System.out.print("대각선의 길이는 "+A);

}

2020/01/02 08:42

제임스상

print((int(input())**2 + int(input())**2)**0.5)

2020/01/03 11:28

BlakeLee

#include<stdio.h>
#include<math.h>
int main(){
    int x,y;
    int data;
    scanf("%d %d",&x,&y); 
    data=sqrt(x*x+y*y);
    printf("%d",data);
}

2020/01/04 14:28

곽병혁

package codingdozang;
import java.util.Scanner;
import java.lang.Math;
public class Diagonallength {
    public static void main(String[] args) {
        Scanner scin=new Scanner(System.in);
        System.out.println("x,y를 입력하시오");
        float x=scin.nextInt();
        float y=scin.nextInt();

        float data;
        double answer;
        data=x*x+y*y;
        answer=Math.sqrt(data);
        System.out.print("대각선 길이는"+answer);
    }
}

2020/01/04 14:43

곽병혁

x=input("x=")
y=input("y=")
z=(x**2+y**2)**0.5
print(z)

2020/01/14 12:40

Michael

import math

def trianglediagonal(x,y):
    z = math.sqrt(float(x)**2 + float(y)**2) # ^가 아니다
    return print(z)

trianglediagonal(1,1)

2020/01/14 20:47

H

def getResult(x,y): return (x2+y2)**0.5

2020/01/16 17:19

hekuri he

width = x height = y

print((x 2 + y 2) ** 0.5)

2020/01/18 06:47

김건형

package BMI;

import java.util.Scanner;

public class Pythagorean_theorem {
    public static void main(String args[]) {
        Scanner input1 = new Scanner(System.in);
        int n1 = input1.nextInt();
        int n2 = input1.nextInt();
        System.out.println(Math.sqrt(n1*n1 + n2*n2));
    }
}

2020/01/19 23:59

BlakeLee

파이썬입니다.

한줄짜리 코딩 해봤습니다..

print('대각선의 길이는 {}이다'.format((sum(tuple(map(lambda x: float(x)**2, input().split()))))**(0.5)))

2020/01/26 16:18

우재용

import math

def triangle(a,h):
    return math.sqrt(a*a+h*h)

print(triangle(3,4))

2020/02/02 23:52

maluchi

import math

a = int(input("입력: "))

b = int(input("입력: "))

print(math.sqrt((a**2)+(b**2)))

2020/02/05 17:26

김희준

import math

a= float(input('x='))

b= float(input('y='))

c= math.sqrt(a**2 + b**2)

print(format(c,'.2f'))

2020/02/11 17:08

HyukHoon Kim

x, y = map(int, input('밑변과 높이를 공백으로 분리해 입력하세요').split())
print((x**2+y**2)**(1/2))

2020/02/17 10:42

KMH

include

include

int main(void){ int x,y; int da; scanf("%d %d",&x,&y);

da = sqrt((x*x)+(y*y));

printf("%d",da);

}

2020/02/26 18:56

정승우

import math as m
x = int(input("x의 길이:"))
y = int(input("y의 길이:"))

def getDiagonal() :
    d = m.sqrt(x**2 + y**2)
    return d

diagonal = getDiagonal()
print("대각선 d의 길이는 %.2f입니다."% diagonal)

2020/02/29 11:46

이성민

import os
import math

def calculate():
        a = 0
        x = input("밑변 = ")
        y = input("높이 = ")
                if type(x) != 'int' or type(y) != 'int' or type(x) != 'float' or type(y) != 'float':
                        print('오류: 계산이 불가능 합니다.")
                        os.system('pause')
                else:
                        x = float(x)
                        y = float(y)
                        a = sqrt(x ^ 2 + y ^ 2)
                        return a

2020/03/01 23:03

PythonLover&Master_JK73

from math import *
x = int(input("x"))
y = int(input("y"))

print(sqrt(x**2+y**2))

2020/03/02 16:37

황예진

def diagonal(a, b):
result=(a2 + b2)**0.5
return result

print("x=",end='')
x=int(input ())
print("y=",end='')
y=int(input ())

print ("Diagonal is "+str(diagonal(x,y)))

2020/03/04 06:02

Buckshot

import math
x=int(input("width"))
y=int(input("height"))
print(math.sqrt(x**2+y**2))

2020/03/05 19:02

Caplexian _

a = float(input("x:"))
b = float(input("y:"))
c = round((a**2 + b**2)**0.5, 3)
print(c)

2020/03/05 20:33

Amsters

def sol():
 x = float(input())
 y = float(input())

 result = (x**2 + y**2)**0.5
 return result

2020/03/06 13:29

코린잉

import numpy as np

def diagonal_line(x,y):
    result=np.sqrt(x**2+y**2)

    return result

2020/03/11 23:30

hyojung choi

def diagonal():
    x = float(input("밑변의 길이를 입력하세요. : "))
    y = float(input("높이를 입력하세요. : "))
    return (x ** 2 + y ** 2) ** (1/2)

2020/03/19 23:06

Gibeom Gim

import math

x = eval(input("밑변을 입력하시오: "))
y = eval(input("높이을 입력하시오: "))

diagonal_1 = (x * x) + (y * y)
diagonal = math.sqrt(diagonal_1)
print("대각선의 길이: {}".format(diagonal))

2020/03/19 23:38

ptjddn95

python 3.8

def sqt(x,y):
    return (x**2+y**2)**(1/2)

x=3.
y=4.
print('%5.2f' % sqt(x,y))

2020/03/23 17:05

mr. gimp

// 피타고라스정리
double a, b;
double Dist = sqrt( (a*a) + (b*b));

2020/04/10 17:09

길고양이

import java.lang.Math; import java.util.Scanner;

public class triSide { static void hypoCal(float a, float b) { float hypo = (float) Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); System.out.printf("빗변의 길이 : %.2f", hypo); }

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.print("밑면 : ");
    float a = sc.nextFloat();
    System.out.print("높이 : ");
    float b = sc.nextFloat();

    hypoCal(a, b);
}

}

2020/04/15 19:33

Dalno

import math
x=eval(input('밑변 : '))
y=eval(input('높이 : '))

print('대각선 길이는 ',math.sqrt(x*x+y*y))

2020/04/19 23:54

양양짹짹

f = lambda x,y : (x**2+y**2)**0.5

print(f(3,4))

2020/04/27 15:15

쭈씨

파이썬입니다.

x = int(input("직각삼각형의 밑변을 입력하시오. : "))
y = int(input("직각삼각형의 높이를 입력하시오. : "))

a = (x**2 + y**2)**0.5
b = round(a, 3)

if len(str(a)) > len(str(b)):
    print(f"남은 변의 길이는 약 {b}입니다.")
else:
    print(f"남은 변의 길이는 {int(a)}입니다.")

2020/05/09 10:36

peca lee

import math
def length():
    x = int(input())
    y = int(input())
    result = math.sqrt(x**2+y**2)
    print(result)

2020/05/09 23:38

Money_Coding

package main

import (
    "fmt"
    "math"
)

func main() {
    var a int
    var b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Printf("%0.2f\n", math.Pow((float64)((a*a)+(b*b)), 0.5))
}

2020/06/08 11:59

BlakeLee

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << pow((a*a) + (b*b), 0.5) << endl;
}

2020/06/08 12:10

BlakeLee

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string c = Console.ReadLine();
            a = Int32.Parse(c.Substring(0,1));
            b = Int32.Parse(c.Substring(2));
            Console.WriteLine(Math.Pow(Convert.ToDouble((a * a) + (b * b)), 0.5));
        }
    }
}

2020/06/08 13:01

BlakeLee

Go

package main

import (
    "fmt"
    "math"
)

func main() {
    var x, y float64
    var n int
    var err error

    fmt.Print("밑변과 높이를 입력해주세요: ")
    n, err = fmt.Scanf("%f %f\n", &x, &y)

    if (n == 2) && (err == nil) && (x > 0) && (y > 0) {
        // 정상 입력
        fmt.Printf("대각선 길이는 %f입니다.\n", math.Sqrt(math.Pow(x, 2)+math.Pow(y, 2)))
    } else {
        fmt.Println("잘못된 값을 입력하였습니다.")
    }
}

2020/07/06 18:28

구루마

파이썬으로 작성하였습니다.

def diagonal(x,y):
    return ((x**2)+(y**2))**(0.5)

try:
    base = float(input("직각삼각형의 밑변의 길이를 입력하세요:"))
    vertical = float(input("직각삼각형의 높이의 길이를 입력하세요:"))
    if base <= 0 or vertical <= 0:
        print("길이는 양의 값이어야 합니다.")
    else:
        print(diagonal(base,vertical))
except:
    print("오류입니다. 숫자를 입력해주세요.")

2020/08/19 19:31

코딩수련수련자

puts ((gets.chomp().to_i**2 + gets.chomp().to_i**2)**0.5)

2020/08/25 00:51

BlakeLee

a = input("밑변")
b = input("높이")
c = (a**2 + b**2) **0.5
print(x)

2020/09/10 21:59

Terry

using System;

namespace _61일차_10월01일
{        
    class MainApp
    {
        static void Main(string[] args)
        {
            Console.Write("Width Value : ");
            string input_Width = Console.ReadLine();
            Console.Write("Height Value : ");
            string input_Height = Console.ReadLine();
            double Result = Math.Pow(int.Parse(input_Width),2) + Math.Pow(int.Parse(input_Height),2);

            Console.WriteLine($"대각선의 길이는 : {Result}");
        }
    }
}

2020/10/01 21:45

MinSeung Kang

import math
def diagonal(x,y):
    return math.sqrt(pow(x,2)+pow(y,2))
print(diagonal(3,4))
print(diagonal(9,12))

2020/10/26 10:00

AppleFarmer

diagonol = lambda x, y: print((x ** 2 + y ** 2) ** 0.5)

2020/11/23 15:06

김우석

diagonal = lambda x,y: (x**2 + y**2)**0.5

print(diagonal(3,4))

2020/11/26 08:18

DSHIN

from math import *

def diagonal(x,y):

  return sqrt(x*x+y*y)

2020/12/10 19:11

전준혁

def diag(x,y):
    return (x**2+y**2)**(0.5)

2020/12/27 10:23

hankyu

파이썬입니다.

>>> import math
>>> def triangle(x,y):
...     return math.sqrt(x**2 + y**2)

아래는 사용 예시입니다.

>>> triangle(3, 4)
5.0

2021/01/10 20:36

이준우

hypo = lambda x, y:(x**2+y**2)**0.5

2021/01/19 13:57

손우민

import math
x,y = map(int,input().split(" "))
line = x**2 + y**2
print(int(math.sqrt(line)))

2021/02/17 20:48

개촙오

def hypo(b, h):
    import math
    b = int(input('Enter base: '))
    h = int(input('Enter height: '))

    hyp = math.sqrt(b ** 2 + h ** 2)

    return hyp

length = hypo(4, 3)
print(length)

2021/02/17 23:22

Ael Lee

def find_z(x, y):
    z = (x**2 + y**2)**0.5
    return z

print(find_z(3, 4))

2021/02/22 17:25

asdfa

x=float(input('밑변 입력'))
y=float(input('높이 입력'))

z = (x**2 + y**2)**0.5

print(z)

2021/03/11 08:19

최우진

a=float(input("밑변 입력 : "))
b=float(input("높이 입력 : "))
c=(a*a+b*b)**(0.5)
print("대각선의 길이는 ",round(c,2),"입니다")

2021/03/28 23:04

GammaKnight

def get_diagonal():
    a = float(input())
    b = float(input())
    return (a**2 + b**2)**0.5

print(get_diagonal())

2021/04/12 13:00

잘해보자

import math
z = lambda x,y : math.sqrt(x**2+y**2)

2021/05/19 23:18

ss2663

#codingdojing_diagonal

import math

x, y = map(int, input().split())

#pythagorean theorem

print('z:', math.sqrt(x**2 + y**2))

2021/07/14 20:54

Jaeman Lee

python 3.7

a = float(input("밑변의 길이를 입력하세요 : "))
b = float(input("높이의 길이를 입력하세요 : "))
c = round(((a**2)+(b**2))**0.5, 3)
print(f"대각선의 길이는 {c} 입니다")

2021/09/13 12:00

ulhangry

f= lambda x,y : (x**2 +y**2)**0.5
print(f(3,4))

2021/09/19 16:42

ninanino

def byun():
    x = int(input("밑변을 입력하세요: "))
    y = int(input("높이를 입력하세요: "))
    z = (x**2+y**2)**0.5
    print(f"대각선 길이는 {round(z,2)} 입니다")

byun()

2021/09/29 14:38

한고선

static void hypotenuse(int x, int y) {
        System.out.println(Math.sqrt(x*x+y*y));
    }

    public static void main(String[] args) {
        hypotenuse(3,4);
    }

2021/10/24 18:23

박대현

import math

x= int(input("밑변의 길이는 :"))
y= int(input("높이 길이는 :"))


dialog_line = math.sqrt(x**2+y**2)
print("대각선의 길이는 ",dialog_line,"입니다")

2021/12/18 17:19

양캠부부

import math
length = float(input("Enter 밑변: "))
height = float(input("Enter 높이: "))
print(math.sqrt(length**2 + height**2))

2021/12/23 14:31

용가리

x,y = input().split()
print(math.sqrt(int(x)*int(x)+int(y)*int(y)))

2022/01/26 11:16

로만가

def f(x,y):
    result = (x*x+y*y)**(1/2)
    return print(result)

2022/03/14 19:03

박건호

import math

def findDiagonal(x, y):
  return math.sqrt(x**2 + y**2)

findDiagonal(3, 4)

2022/03/21 11:37

Charles

x = float(input("가로의 길이를 입력하시오."))
y = float(input("세로의 길이를 입력하시오."))

i = (x**2+y**2)**0.5

print(i)

2022/03/21 15:37

KORRNOI

x,y = map(int,input("삼각형의 밑변, 높이를 각각 입력하세요:").split())

height = (x**2 + y**2)**0.5
print(height)

2022/04/22 14:37

seolgyung jeong

import math

def slope(x, y):
    sl = math.sqrt(x**2 + y**2)
    return sl

2022/05/03 17:04

Kipum Jung

package com.algorithm.algorithmpractice.dojang;

public class GetLength {
    private static double getLength(int a, int b){
        double result = Math.pow(a, 2) + Math.pow(b, 2);
        result = Math.sqrt(result);
        return result;
    }
    public static void main(String[] args) {
        System.out.println("result: " + getLength(4, 4));
        System.out.println("expected: " + Math.sqrt(32));
    }
}

2022/05/12 07:12

inkuk ju

Python

import math
x = 0
y = 0
result = 0
x = int(input("x값 입력: "))
y = int(input("y값 입력: "))
result = math.sqrt(x**2 + y**2)
print(result)

Java

import java.util.*;

class diagonal {
    public static void main(String[] args)
    {
        int x = 0, y = 0;
        double diagonal = 0.0;

        System.out.printf("x와 y의 값을 입력해주세요");
        Scanner scanner = new Scanner(System.in);
        x = scanner.nextInt();
        y = scanner.nextInt();

        diagonal = Math.sqrt(Math.pow(x,2) + Math.pow(y,2));

        System.out.printf("%f", diagonal);
    }
}

2022/06/21 23:44

김성범

하스켈 처음 써봅니다. 와 악명높은 이유를 알겠네...

-- 직각삼각형 밑변x, 높이y로부터 대각선의 길이 구하기
module Main where

main :: IO ()
main = do
  x <- fmap read getLine :: IO Float
  y <- fmap read getLine :: IO Float
  let diagonal a b = sqrt (a * a + b * b)
  print (diagonal x y)

2022/07/05 23:13

Noname

def right_triangle(x, y):
    import math

    z = x*x + y*y

    return math.sqrt(z)

파이썬으로 만들었습니다.

2022/07/10 23:20

박종훈

def diag_tri():
    a = float(input("직각삼각형의 대각선 길이를 구합니다.\n밑변 입력>> "))
    b = float(input("높이 입력>> "))
    d = (a*a + b*b)**0.5
    return d
print(diag_tri())

파이썬 3.9

2022/07/13 14:54

Estelle L

import math
x = int(input("enter the base length of the triangle:"))
y = int(input("enter the height of the triangle:"))

diagonal = math.sqrt(x**2 + y**2)
print(diagonal)

2022/07/19 16:46

쑥갓

def z(x, y):
    return (x ** 2 + y ** 2) ** 0.5

python

2023/01/10 14:10

마라떡볶이

python

import numpy as np

def cal_diagonal():
  x = 1
  y = np.sqrt(3)
  dia = np.sqrt(x**2+y**2)
  return dia

if __name__== '__main__':
  diagonal = cal_diagonal()
  print(diagonal)

2023/02/18 18:10

세라

import math
def diagonal(x, y):
  return math.sqrt(x**2+y**2)

2023/07/20 16:07

스탠리

x,y = map(int,input("X Y:").split())
print("{:.2f}".format(float((x**2+y**2)**0.5)))

2023/08/10 18:34

siu yoon

#include <stdio.h>
#include <math.h>

int res(float x, float y){
  float res = sqrt(pow(x, 2) + pow(y, 2));

  printf("%.2f\n", res);
}

int main(void){
  float x, y;

  scanf("%f %f", &x, &y);

  res(x, y);

  return 0;
}

2024/03/06 08:28

WG JN

package free;

import java.util.Scanner;

public class test3 {
    public static Scanner sc;
    public static int getSquare(int number) {
        return number * number;
    }
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        System.out.print("x좌표 입력 : ");
        int x = sc.nextInt();
        sc.nextLine();
        System.out.print("y좌표 입력 : ");
        int y = sc.nextInt();
        System.out.println("남은 변 길이는 : " + Math.sqrt(getSquare(x) + getSquare(y)));
    sc.close();
    }
}

Math.sqrt() 함수를 자체 구현하려 했는데 어떻게 구현해야할까용

2024/05/14 21:20

최영빈

import math

x = float(input("직각삼각형의 밑변 길이: "))
y = float(input("직각삼각형의 높이 길이: "))

print(f"직각삼각형의 빗변 길이는 %.3f이다."%(math.sqrt(x**2+y**2)))


#==============함수정의=============
def sqrt_cal(x,y):
    import math
    hypotenuse = float(math.sqrt(x**2+y**2))
    return hypotenuse

2025/08/24 11:05

허거덩

목록으로