此函数查找两个数字的平方和的平方根。它代表斜边,用于查找直角三角形的斜边。
直角三角形的语法为:
double hypot(double x, double y); float hypot(float x, float y); long double hypot(long double x, long double y); promoted hypot(type1 x, type2 y);
3d空间的语法为:
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-hypot-function.html
来源:LearnFk无涯教程网
double hypot(double x, double y, double z); float hypot(float x, float y, float z); long double hypot(long double x, long double y, long double z); promoted hypot(type1 x, type2 y, type3 z);
(x,y,z) : x,y和z是float或整数类型的值。
它返回两个数字的平方和的立方根。
让我们看一个简单的例子。
#include <iostream> #include<cmath> using namespace std; int main() { int x=2; int y=3; cout<<"sides of a right angled triangle are :"; cout<<x<<","<<y<<'\n'; cout<<"third side of a triangle is :"<<hypot(x,y); return 0; }
输出:
sides of a right angled triangle are :2,3 third side of a triangle is :3.60555
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)