![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 七嘴八舌異言堂
(https://www.pcdvd.com.tw/forumdisplay.php?f=12)
- - 請問幾個C++的問題
(https://www.pcdvd.com.tw/showthread.php?t=331514)
|
|---|
請問幾個C++的問題
請問假如我要輸入一堆數子
最後要求出這一系列數字的幾何平均數 該如何求?? 幾何平均數: (a1*a2*a3......*an)^1/n 問題是C++的開n次方根號的語法不知道 請問有人知道如何求嗎?? |
int a[n]; /*n=總共幾項*/
int sum=0; double result; for (int i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; } result=sum/n; cout<<result; 開更號喔 include<math.h> 然後就可以用 sqrt(xxx); 就降 剛好在念 順手回一下,有錯記的講阿... |
謝謝~~不過sqrt只是開平方根
剛好陣列蠻爛的~感謝教學 剛好看到 開次方根的語法 pow(x,1./3); 即x^1/3 THANKS |
| 所有的時間均為GMT +8。 現在的時間是02:43 AM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2026。