编程中问题,请高手指教
#include<stdio.h>double x;
int n;
double power( double x,int n )
{if(n=1)
return x;
else if(n=0)
return 1;
else if(n<1)
{power (x,n+1);
x=x*x;
x=1/x;
return x;}
else
{power(x,n-1);
x=x*x;
return x;}
}
int main (void)
{
printf("writedown:");
scanf("%lf",&x);
printf("writedown:");
scanf("%d",&n);
x=power(x,n);
printf("%20.15e",x);
return 0;}
输入3.5,7,输出为12.25,
输入3.5,2,输出相同,为何?!