English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutorial básico de linguagem C

Controle de fluxo de linguagem C

Funções do C

Matriz do C

Ponteiro do C

String do C

Estrutura de linguagem C

Arquivo de linguagem C

Outros C

Manual de referência do C

Uso e exemplo da função hypot() da biblioteca C

Head <math.h> do C

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.

原型 da função hypot()

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

Exemplo: Função hypot() em C

#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,

Head <math.h> do C