[C++] hypot
개요
- 인자가 2개(C++11)면 직각 삼각형의 빗변, 3개(C++17)면 원점으로부터의 거리를 반환하는 함수
예제
- 코드
#include <cmath> #include <iostream> using namespace std; int main() { cout << hypot(3, 4) << endl; cout << hypot(1, 2, 3) << endl; return 0; } - 실행 결과
5 3.74166
#include <cmath>
#include <iostream>
using namespace std;
int main() {
cout << hypot(3, 4) << endl;
cout << hypot(1, 2, 3) << endl;
return 0;
}
5
3.74166