目前,我的最佳努力导致奥洛(log2)的复杂性:
int power(x,n)
{
int mult=1, temp=x, i=1, j=1;
while (n>1)
{
mult=mult*x;
x=temp;
for (i=1;i<=log[n];i++)
{
x=x*x;
j=j*2;
}
n=n-j;
i=1;
j=1;
}
if (n==1)
return (mult*temp);
return (mult);
}
P.S Thank you funkymushroom for helping me with my bad English :)