English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Biblioteca estándar <math.h> en C
El lado más largo del triángulo rectángulo es la hipotenusa. Cuando se proporcionan los otros dos lados, la función hypot() se utiliza para calcular la longitud del lado más largo del triángulo rectángulo.
double hypot(double p, double b);
En matemáticas, h = √(p2+b2) es equivalente en programación en C a h = hypot(p, b);。
La función hypot() enmath.h Se define en el archivo de cabecera
#include <stdio.h> #include <math.h> int main() { double p, b; double hipotenusa; p = 5.0; b = 12.0; hipotenusa = hypot(p, b); printf("hypot(%.2lf, %.2lf) = %.2lf", p, b, hipotenuse); return 0; }
Resultados de salida
hypot(5.00, 12.00) = 13.00