这里是我的代码:基本功能生产无限循环
#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)'。 –
代码中没有无限循环if处理*输入*时遇到问题,就这么说... –