hypot() 函数原型
double hypot(double p, double b);
数学中的 h = √(p2+b2)
等价于 C 语言编程中的 h = hypot(p, b);
。
hypot() 函数定义在 math.h 头文件中。
示例:C hypot() 函数
#include <stdio.h>
#include <math.h>
int main()
{
double p, b;
double hypotenuse;
p = 5.0;
b = 12.0;
hypotenuse = hypot(p, b);
printf("hypot(%.2lf, %.2lf) = %.2lf", p, b, hypotenuse);
return 0;
}
输出
hypot(5.00, 12.00) = 13.00