double solve(double x,int n){ double fv; if (n==1) return x; if (n%2==0) { fv=solve(x,n/2); return fv*fv; } else { fv=solve(x,(n-1)/2); return fv*fv*x;} }上面程序的递归模型是:f(n)=a; n==1 f(n)= f(n/2)* f(n/2) *a; n>1
double solve(double x,int n){ double fv; if (n==1) return x; if (n%2==0) { fv=solve(x,n/2); return fv*fv; } else { fv=solve(x,(n-1)/2); return fv*fv*x;} }上面程序的递归模型是:f(n)=a; n==1 f(n)= f(n/2)* f(n/2) *a; n>1
发布时间:2024-09-26 00:00:40