问题描述:
这还描述啥
解决思路:
递归,递推,以及logn的解法,第三种解法中,若n为偶数,x*n = x*(n/2)*x*(n/2);若n为奇数,x*n=x*(n/2)*x*(n/2)*x;
算法实现:
#include<stdio.h>
double recursion(double x, int n);
double recurrence(double x, int n);
double logn(double x, int n);
int main() {
double x;
int n;
while(scanf("%lf%d",&x,&n)){
printf("%lf\n",recursion(x,n));
printf("%lf\n",recurrence(x,n));
printf("%lf\n",logn(x,n));
}
return 0;
}
double recursion(double x,int n) {
if(n == 0