系统只提供下面参数类型的pow函数……
C/C++ code
double pow(double, double)long double std::pow(long double, int) float std::pow(float, int)double std::pow(double, int)long double std::pow(long double, long double)float std::pow(float, float)
例子:
int main(int argc, char *argv[]){ int x=2.0,y=3,z; z=pow(x,y); return z;}
求x的y次幂如果你要求2的4次幂,就写 pow(2,4),它就算出来了.
//假设要计算2的10次方
#include
#include
void main()
{
int data = pow(2,10);
printf("%d",data);
}
Example:
/* pow example */
#include/* printf */
#include/* pow */
int main ()
{
printf ("7 ^ 3 = %f\n", pow (7.0, 3.0) );
printf ("4.73 ^ 12 = %f\n", pow (4.73, 12.0) );
printf ("32.01 ^ 1.54 = %f\n", pow (32.01, 1.54) );
return 0;
}
Output:
7 ^ 3 = 343.000000
4.73 ^ 12 = 125410439.217423
32.01 ^ 1.54 = 208.036691
参考链接:http://www.cplusplus.com/reference/cmath/pow/