ABS绝对置?3Q
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/31 12:28:55
ABS绝对置?3Q
ABS绝对置?3Q
ABS绝对置?3Q
1.绝对值的代数定义 一个正数的绝对值是它本身;一个负数的绝对值是它的相反数;零的绝对值是零. 2.绝对值的几何定义 在数轴上表示一个数的点离开原点的距离,叫做这个数的绝对值. abs() 函数 是用来求绝对值的 其函数代码 abs Calculates the absolute value.int abs( int n ); Routine Required Header Compatibility abs or ANSI,Win 95,Win NT For additional compatibility information,see Compatibility in the Introduction.Libraries LIBC.LIB Single thread static library,retail version LIBCMT.LIB Multithread static library,retail version MSVCRT.LIB Import library for MSVCRT.DLL,retail version Return Value The abs function returns the absolute value of its parameter.There is no error return.Parameter n Integer value Example /* ABS.C:This program computes and displays * the absolute values of several numbers.*/ #include #include #include 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