abs C语言 是啥

来源:百度知道 编辑:UC知道 时间:2024/05/12 12:51:43

求绝对值函数
abs么,就是
absolute
adj.
绝对的; 完全的, 纯粹的, 净的

abs 函数是求绝对值函数,返回整形int
函数描述:INT abs( int n );
需要头文件:<stdlib.h> or <math.h>
例子:
#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

在<math.h>头文件中..去绝对值函数...

取绝对值

取绝对值