#include<iostream>
using namespace std;
float power(float x,int y)
{
float temp;
if(y==0)
return 1;
temp = power(x, y/2);
if(y%2==0)
return temp * temp;
else
{
if(y>0)
return(x*temp*temp);
else
return(-x*temp*temp);
}
}
int main()
{
float x;
int y;
cin>>x>>y;
cout<<power(x,y);
return 0;
}
标签:幂函数,分治,return,power,temp,求解,int,float
From: https://www.cnblogs.com/vvvv214/p/16731437.html