新手求助 递归问题 运行结果返回的第一个scanf输入的值

#include

double power(double x,int n);
int main()
{
double x=0;
int n=0;
double relust=0;
printf("\nEnter the base and index you want:");
scanf("%lf",&x);
scanf("%d",&n);
printf("%lf %d",x,n);
relust=power(x,n);
printf("\nrelust=%lf",relust);
getchar();
getchar();
return 0;
}

double power(double y,int x)
{
if(x=1)
return y;

return y*power(y,x-1);

}

if(x=1)

if( x == 1)

一般初学者最好
if(1 == x)
避免
if(x=1)
都不知道错哪了。

if (x = 1) 这样是给x 赋值,结果是true ,(x == 1) 是判断x 的值是否和1相等,返回第一个是因为你第一个输入就是power里的y
if 判断一直走的第一步