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 斯卡 阅读(2936) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理