C++中沒有乘方符號,需要計算乘方時要用到pow()函數,要注意三點:
1、#include<cmath>或者#include<math.h>
2、重載形式:
float pow (float, float); //cmath中
float pow (float, int); //cmath中
double pow (double, double); //math.h中
3、pow(x,y)僅在x > 0時返回值
ps:如果只是想算10的p次方的話,可以使用double pow10(int)
posted on 2008-06-20 00:24
斯卡 閱讀(3008)
評論(0) 編輯 收藏 引用