问题描述:
C语言我定义一个函数来求x的n次方.我的为什么不可以.
#include
int power(double x,int n)
{
double y;
y=x;
while(n>1)
{
y*=x;
n--;
}
return(y);
}
void main()
{
double a;
int b;
scanf("%f%d",&a,&b);
printf("a的b次方为:%f",power(a,b));
}
为什么求不了,输出是0.000000.
#include
int power(double x,int n)
{
double y;
y=x;
while(n>1)
{
y*=x;
n--;
}
return(y);
}
void main()
{
double a;
int b;
scanf("%f%d",&a,&b);
printf("a的b次方为:%f",power(a,b));
}
为什么求不了,输出是0.000000.
问题解答:
我来补答展开全文阅读