我是C的新手。我想编写一个程序来计算Hypotenuse,但是当我运行它时,我得到了垃圾值,我不知道如何处理它。我怎么处理垃圾?
double Hypotenuse(double base, double perpendicular)
{
double hyp = sqrt((base*base) + (perpendicular*perpendicular));
return hyp;
}
int _tmain(void)
{
double b, p;
printf("Enter the lenght of base\n");
scanf_s("%f",&b);
printf("Enter the lenght of perpendicular\n");
scanf_s("%f",&p);
printf("The hypotenuse of the triangle is %3.3f",Hypotenuse(b,p));
return 0;
}
使用' “%LF”''为 – BLUEPIXY
double' @BLUEPIXY为什么会这样?你的意思是在scanf?我在看printf。 –
喜欢你的标题 – bolov