目录
包含头文件:<math.h>
C90函数原型:double fabs (double x);
C99函数原型:
- double fabs (double x);
- float fabsf (float x);
- long double fabsl (long double x);
C++98函数原型:
- double fabs (double x);
- float fabs (float x);
- ong double fabs (long double x);
C++11函数原型:
- double fabs (double x);
- float fabs (float x);
- long double fabs (long double x);
功能:返回参数的绝对值
注意事项:参会不局限于单纯的数字,可以是有返回参数的函数,fabs函数的参数个数只能有一个,但是可以是两个函数返回值运算的的结果,比如:fabs(height(root->left) - height(root->right))
实例:
/* fabs example */
#include <stdio.h> /* printf */
#include <math.h> /* fabs */
int main ()
{
printf ("The absolute value of 3.1416 is %f\n", fabs (3.1416) );
printf ("The absolute value of -10.6 is %f\n", fabs (-10.6) );
return 0;
}
包含头文件:<math.h>
C99函数原型:?
- double fmax (double x , double y);
- float fmaxf (float x , float y);
- long double fmaxl (long double x, long double y);
C++11函数原型:
- double fmax (double x , double y);
- float fmax (float x , float y);
- long double fmax (long double x, long double y);
- double fmax (Type1 x , Type2 y);
功能:返回其参数中较大的参数?
实例:
/* fmax example */
#include <stdio.h> /* printf */
#include <math.h> /* fmax */
int main ()
{
printf ("fmax (100.0, 1.0) = %f\n", fmax(100.0,1.0));
printf ("fmax (-100.0, 1.0) = %f\n", fmax(-100.0,1.0));
printf ("fmax (-100.0, -1.0) = %f\n", fmax(-100.0,-1.0));
return 0;
}
~over~