C语言编写求x开n次方

来源:百度知道 编辑:UC知道 时间:2024/06/04 01:02:14
越快越好,谢谢
用递归解,不用cmath

#include <stdio.h>
#include <math.h>

int main(){
double x,n;
printf("Enter the value of x: ");
scanf("%lf",x);
printf("Enter the value of n: ");
scanf("%lf",n);
printf("The nth root of x is %f.\n",pow(x,1.0/n));
return 0;
}

你问的到底是什么?是x的n次方还是x的n次根?n次方的话可以用递归,n次根的话是不行的。你认为怎么用递归来求n次根?