Some characters as follows:
pow
Calculates x raised to the power of y.
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 2.0, y = 3.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f/n", x, y, z );
}
Output
2.0 to the power of 3.0 is 8.0
fabsCalculates the absolute value of the floating-point argument.#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void main( void )
{
int ix = -4, iy;
long lx = -41567L, ly;
double dx = -3.141593, dy;
iy = abs( ix );
printf( "The absolute value of %d is %d/n", ix, iy);
ly = labs( lx );
printf( "The absolute value of %ld is %ld/n", lx, ly);
dy = fabs( dx );
printf( "The absolute value of %f is %f/n", dx, dy );
}
Output
The absolute value of -4 is 4
The absolute value of -41567 is 41567
The absolute value of -3.141593 is 3.141593
sqrt
Calculates the square root.
Ex:
answer = sqrt( question );
The book <<ObjectARX>> is not very good I think .
本文介绍了三个基本数学函数的应用实例:幂运算函数pow用于计算x的y次方;绝对值函数fabs用于计算浮点数的绝对值;平方根函数sqrt用于求解数值的平方根。这些函数常见于C/C++等编程语言的数学库中。
146

被折叠的 条评论
为什么被折叠?



