數值的整數次方

2021-10-03 04:14:27 字數 687 閱讀 9220

實現函式double power(double base, int exponent),求base的exponent次方。不得使用庫函式,同時不需要考慮大數問題。

示例 1:

輸入: 2.00000, 10

輸出: 1024.00000

示例 2:

輸入: 2.10000, 3

輸出: 9.26100

示例 3:

輸入: 2.00000, -2

輸出: 0.25000

解釋: 2-2 = 1/22 = 1/4 = 0.25

說明:-100.0 < x < 100.0

n 是 32 位有符號整數,其數值範圍是 [−231, 231 − 1] 。

注意:本題與主站 50 題相同:

數值整數次方

題目 實現函式double power double base,int exponent 求base的exponent次方。不得使用庫函式,同時不需要考慮 大數問題。includebool equal double num1,double num2 double powerwithunsignede...

數值整數次方

題目 實現函式double power double base,int exponent 求base的exponent次方。不得使用庫函式,同時不需要考慮 大數問題。includebool equal double num1,double num2 double powerwithunsignede...

數值的整數次方

題目 實現函式double power double base,int exponent 求base的exponent次方。不得使用庫函式,同時不需要考慮大樹問題。這道題目有以下幾點需要注意 0的0次方是無意義的,非法輸入 0的負數次方相當於0作為除數,也是無意義的,非法輸入 base如果非0,如果...