c - 程序运行,但结果错误......是一个找到矩形三角形缺失边并找到其角度的程序

标签 c

这是我到目前为止的代码:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void pitagoras(float l1, float h);
void angulo(float l1, float l2);

int main() {
    float lado1, hipotenusa;
    printf("sea el triangulo del tipo ABC siendo C la hipotenusa con angulo opuesto c=90\n        y el angulo b opuesto al lado 1");
    printf("ponga la hipotenusa:\n");
    scanf("%f", &hipotenusa);
    printf("ponga el lado 1:\n");
    scanf("%f", &lado1);
    pitagoras(lado1, hipotenusa);
    angulo(lado1, lado2);
    return 0;
}

void pitagoras(float l1, float h) {
    if(l1 >= h) {
        printf("error, no es un triangulo rectangulo");
    }
    else {
        float l2;
        l2= sqrt(h*h - l1*l1);
        printf("el lado 2 es:%f", l2);
    }
}

void angulo(float l1, float l2) {
    float angulob, anguloa;
    angulob= atan(l1 / l2);
    anguloa = 180 - (angulob + 90);
    printf("los angulos a y b son:%f, %f", angulob, anguloa);
}

出于某种原因,无论我使用哪个数字,我在 l2 中都会得到 1。我该如何解决这个问题?

最佳答案

关于c - 程序运行,但结果错误......是一个找到矩形三角形缺失边并找到其角度的程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21957827/

相关文章:

c - 可变长度数组如何在 C 中对齐?

c - C 函数的动态接口(interface)

c++ 将存储在 std::vector 中的数据传递给 c_func(void* data)

c - 在 C 中使用 fopen() 使用字符数组作为文件名

c - nf_reset() 这个函数是做什么的?

python - Python 和 C 的单一源文件

c - 接口(interface)绑定(bind)

c - 想知道如何 "reveal"一个 "hidden"字符串(格式如 ****)

c - 未初始化的 C 结构字段

c - 如何使用 fprintf 并写入管道?