English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

標題規定三十個字@@沒辦法打清楚~我在下面打詳細問各位大大
設計一個函數integerPower( base, exponent ),使他能夠傳回以下的數值
base的exponent的多少次方
例如,integerPower( 3 , 4 ) = 3 * 3 * 3 * 3。假設exponent是正的數值、非零的整數,而base則是一個函數。但是只能用For或是while結構來控制計算。不能用數學函數庫的函數。

2006-06-21 20:27:08 · 1 個解答 · 發問者 ☆↗呆呆↗☆ 1 in 電腦與網際網路 程式設計

其實~我要問ㄉ是C程式....很抱歉~在貼上ㄉ時候~忘記修改我要問的是屬於哪一類的.....>"<
不過也很感謝你...VB剛剛也有測試過了
3Q

2006-06-21 21:34:46 · update #1

1 個解答

Function IntegerPower(ByVal Base As Integer, ByVal Exponent As Integer) As Double    Dim I As Integer, B As Integer        If Exponent < 1 Then Exit Function    B = 1    If Base < 0 Then B = -1    IntegerPower = 1: Base = Abs(Base)    For I = 1 To Exponent        IntegerPower = IntegerPower * Base    Next    IntegerPower = IntegerPower * BEnd FunctionPrivate Sub Command1_Click()    Print IntegerPower(2, 4)End Sub

2006-06-21 20:47:11 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers