/*************************************************************************
> File Name: 09_Power.c
> Author: Juntaran
> Mail: JuntaranMail@gmail.com
> Created Time: 2016年08月29日 星期一 21时07分21秒
************************************************************************/ #include <stdio.h> double Power(double base, int exponent)
{
if (base == )
return ;
if (exponent == )
return ;
if (exponent == )
return base; int x = abs(exponent);
double r = 1.0; while (x)
{
if (x & )
r *= base;
base *= base;
x >>= ;
printf("r is %f\n base is %f\n x is %d\n", r, base, x);
}
return exponent< ? /r : r;
} int main()
{
double base = ;
int exponent = ;
double ret = Power(base, exponent);
printf("ret is %f\n", ret); return ;
}