我正在编写在 c++ 中不使用 pow() 的代码,但是我遇到了很多我无法弄清楚的错误:
double power (double X, unsigned int N)
{
double value;
unsigned int i = 1;
for (i = 1, i <= N, i++)
{
result = result * X;
}
if (finite(result))
{
return result;
}
else
{
return INFINITY;
}
}
错误:
In function 'double power(double, unsigned int)':
Line 5: warning: right-hand operand of comma has no effect
Line 5: error: expected ';' before ')' token
Line 10: error: expected primary-expression before 'if'
Line 10: error: expected ';' before 'if'
Line 10: error: expected primary-expression before 'if'
Line 10: error: expected ')' before 'if'
任何帮助将不胜感激,谢谢。