曲径通幽论坛

标题: hypot() -- 计算直角三角形的斜边长 [打印本页]

作者: beyes    时间: 2011-12-23 11:31
标题: hypot() -- 计算直角三角形的斜边长
hypot() 原型如下:
[C++] 纯文本查看 复制代码
#include <math.h>
double hypot(double x, double y);

hypot() 用来计算三角形的斜边程度,它实际上是通过调用 sqrt (x*x, y*y); 来计算的,然后返回结果值。

测试代码
[C++] 纯文本查看 复制代码
#include <stdio.h>
#include <math.h>

int main()
{
    double dis;

    dis = hypot(3,4);
   
    printf ("the distance = %f\n", dis);

    return 0;
}

运行输出:
./hypot
the distance = 5.000000





欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2