c语言pow的用法
英文屋
人气:2.55W
C语言中pow函数用于计算x的y次幂。下面我们来看看c语言pow的用法。 pow函数有以下几种的重载形式: double pow(double X,int Y); float pow(float X,float Y); float pow(float X,int Y); long double pow(long double X,long double Y); long double pow(long double X,int Y); 使用的时候应合理设置参数类型,避免有多个“pow”实例与参数列表相匹配的情况。 其中较容易发生重载的是使用形如: int X,Y; int num=pow(X,Y); 这是一个比较常用的函数,但是编译器会提醒有多个“pow”实例与参数列表相匹配。 可以使用强制类型转换解决这个问题:num=pow((float)X,Y) 原型:extern float pow(float x, float y); 用法:#include 功能:计算x的y次幂。 说明:x应大于零,返回幂指数的结果。 举例: // pow.c #include #include #include void main() { printf("4^5=%f",pow(4.,5.)); getchar(); } #include #include void main( void ) { double x = 2.0, y = 3.0, z; z = pow( x, y ); printf( "%.1f to the power of %.1f is %.1f ", x, y, z ); } Output 2.0 to the power of 3.0 is 8.0
更多推荐
- 1conditional promise是什么意思、英文翻译及中文解释
- 2无用是什么意思、英文翻译及中文解释
- 3倾伏是什么意思、英文翻译及中文解释
- 4这句话英文怎么说(生活篇) 第630期:她只是爱他的钱
- 5第59课:What was the worst restaurant experience you’ve had?
- 6amphistyly是什么意思、英文翻译及中文解释
- 7automatic repeatrequest是什么意思、英文翻译及中文解释
- 8外教口语天天练:第72期
- 9automaticfeed是什么意思、英文翻译及中文解释大纲
- 10不可能图形是什么意思、英文翻译及中文解释
- 11as easy as winking是什么意思、英文翻译及中文解释
- 12比较容易学的英文歌
- 13acw是什么意思、英文翻译及中文解释大纲
- 14artfulness是什么意思、英文翻译及中文解释
- 15主观样本是什么意思、英文翻译及中文解释