C语言想用引入函数来求三角形的第三边 但是结果一直是0.00000不知道哪里出问题了
问题描述:
#include<stdio.h>
#include<math.h>
double hypotenuse(double a,double b);
int main()
{
double a,b,f;
printf("Please enter the length of both sides:");
/*scanf("%f","%f",&a,&b);*/
scanf("%f",&a);
scanf("%f",&b);
f= hypotenuse(a,b);
printf("The hypotenuse of a triangle is %f",f);
return 0;
}
double hypotenuse(double c,double d)
{
double e;
e=sqrt(c*c+d*d);
return e;
}
结果一直是0.0000
答
scanf("%lf",&a);
scanf("%lf",&b);
a,b都是double类型的