English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
O lado mais longo do triângulo retângulo é a hipotenusa. Quando são fornecidas as outras duas laterais, a função hypot() é usada para calcular o comprimento da hipotenusa do triângulo retângulo.
double hypot(double p, double b);
Matematicamente, h = √(p2+b2) é equivalente ao código em C: h = hypot(p, b);。
A função hypot() emmath.h Definida no cabeçalho
#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, %.2printf("hypot(%.2lf, %. lf) = %. lf", p, b, hipotenuse);
return 0;
}5Resultado de saída 12hypot( 1300,