ABS绝对置?3Q

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 01:06:12
ABS绝对置?3QABS绝对置?3QABS绝对置?3Q1.绝对值的代数定义一个正数的绝对值是它本身;一个负数的绝对值是它的相反数;零的绝对值是零.2.绝对值的几何定义在数轴上表示一个数的点离开原点的距

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