|
#include<cmath>
#include<cstdlib>
#include<iostream>
using namespace std;
double Exponent(double x,int n){
if(n==0)
return 1.0;
else {
if(n>0&&n%2==0)
return Exponent(x*x,n/2);
else if(n>0&&n%2==1)
return x*Exponent(x*x,(n-1)/2);
}
}
int main(){
double a=Exponent(4.1,4);
cout<<a<<endl;
}
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-27 06:45
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社