我编写的一个计算整数次幂的程序运行结果为0,不知道为什么,请大神指点!
#include
double power(double n,int p)
{
double pow=1;
int i;
for(i=1;i<=p;i++)
pow*=n;
return pow;
}
int main(void)
{
double x,xexp;
int exp;
scanf("%1f %d",&x,&exp);
xexp=power(x,exp);
printf("%.5g",xexp);
return 0;
}