static double pow(double a, double b)
Returns the value of the first argument raised to the power of the second argument.
所以,呼叫指數函數:
Math.pow(2.0,3)
是2的3次方,參數都是double
,當輸入為int
時會轉為double
題目所用到的[直線距離數學公式]
Math.pow(x1-x2,2)
去做
解答:
Math.sqrt();
用於開根號
Math.pow(x,2);
用於開平方
若要3次方(),則寫成Math.pow(x,3);
Q:
{使用者輸入3個數,印出最大值}
限制條件: 並回傳兩者的最大值
解答(Ans):
int
,但當出現浮點數時,建議還是用double
Math.max(x,y)
為兩數尋找最大值解答:
題目所用到的[運算數學公式]
副程式寫法:
Math.pow(x,2)
去做解答:
最後編輯時間:2021/3/14 12:06pm.
JAVA課堂學習
複習用
高科大