【发布时间】:2015-12-25 00:11:58
【问题描述】:
这是我的代码:
#include <stdio.h>
#include <math.h>
int main(void)
{
double x, y, z;
double numerator;
double denominator;
printf("This program will solve (x^2+y^2)/(x/y)^3\n");
printf("Enter the value for x:\n");
scanf("%lf", x);
printf("Enter the value for y:\n");
scanf("%lf", y);
numerator = sqrt(x) + sqrt(y);
denominator = pow((x/y),3);
z = (numerator/denominator);
printf("The solution is: %f\n", z);
return(0);
}
谁能给我一个(希望是)快速指针来修复我的无限循环?
【问题讨论】:
-
你应该通过
scanf("%lf", &x);读入变量。 scanf 将修改程序中变量的值,因此您始终需要在函数中传递对变量的引用。 -
sqrt(x)返回平方根,而不是平方。使用pow(x,2)。 -
代码中没有无限循环。如果您在处理 输入 时遇到问题,请说...