C++官网参考链接:https://cplusplus.com/reference/cmath/abs/
函数
<cmath> <ctgmath>
abs
C++98
double abs(double x);
float abs(float x);
long double abs(long double x);
C++11
double abs(double x);
float abs(float x);
long double abs(long double x);
double abs(T x); // additional overloads for integral types
计算绝对值
返回x的绝对值:|x|。
这些方便的abs重载是C++独有的。在C语言中,abs只在<stdlib.h>中声明(并作用于int值)。
从C++11开始,在这个头文件(