C 库函数 hypot() 使用方法及示例 - C语言教程

由网友 大卫 发布 阅读 0

 C 库函数  hypot() 使用方法及示例 - C语言教程

C 标准库 <math.h>

斜边是直角三角形的最长边。当提供其他两边时,hypot()函数用于计算直角三角形的斜边长。

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

C 标准库 <math.h>

C 库函数 atanh() C 标准库 <stdlib.h>