C++中沒(méi)有乘方符號(hào),需要計(jì)算乘方時(shí)要用到pow()函數(shù),要注意三點(diǎn):
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時(shí)返回值
ps:如果只是想算10的p次方的話,可以使用double pow10(int)
posted on 2008-06-20 00:24
斯卡 閱讀(3025)
評(píng)論(0) 編輯 收藏 引用