我必須編寫一個算法,用一個整數或浮點型參數中的一個基數(整數或浮點數)進行指數運算。我寫這個算法洪水(zoho.com),但它只能使用整數指數:浮點型指數運算法則
float math.potencia(float base, int expoente)
{
if(expoente>0)
{
base = base * thisapp.math.potencia(base, (input.expoente - 1));
}
else if (expoente == 0)
{
base = 1;
}
return base;
}
(洪水不具有增強運算符或函數)。謝謝!
你沒有得到回覆,因爲你的問題被標記不良。 – skaffman 2010-12-14 12:47:13
我想如果你吸收我另一個標籤。對於我的分數,我不會創造新的。 – Alex 2010-12-23 10:28:12