温州发布:用c++递归函数求解x的n次幂
来源:百度文库 编辑:中科新闻网 时间:2024/05/06 07:25:11
#include <iostream.h>
float fac(int n,float x);
void main()
{
int n;//
float x;
cin>>n>>x;
cout<<fac(n,x);
}
float fac(int n,float x)
{
if(n==1) return x;
else
return(x*fac(n-1,x));
}
随便找本看下都有