int power(int base, int n)
{
int p;
for (n = 1; n > 0; --n)
p = p * base;
return p;
}
------------
应该这么写
程序代码:
int power (int base, int n)
{
int p = base;
if (n > 1)
{
for (; n > 1; n--)
p = base * p;
}
else if (n == 1)
p = base;
else
p = 1;
return p;
}