C 中没有出现次等性

问题描述 投票:0回答:1
#include <stdio.h>
#include <math.h>

int main() {

    double P;
    double B;

    printf("\nPerpendicular:");
    scanf("%lf", P);
    printf("\n Base:");
    scanf("%lf", B);
    double H = sqrt(P * P + B * B);
    printf("Hypoteneous:%lf", H);

    return 0;
} 

我正在尝试制作一个程序,允许用户通过输入用户的底边和垂直线来找到三角形的斜线,但是当我尝试运行该程序时,它只允许我输入底边和垂直线,而不是只是关闭而不显示低气压

c math runtime-error hypotenuse
1个回答
0
投票

您只需要确保传递了要读入的变量的引用:

    printf("\nPerpendicular:");
    scanf("%lf", &P);
    printf("\n Base:");
    scanf("%lf", &B);
© www.soinside.com 2019 - 2024. All rights reserved.