📅  最后修改于: 2020-09-25 08:52:49             🧑  作者: Mango
llabs() 函数可以视为abs()的long long int
版本。
它在
[Mathematics] |x| = llabs(x) [C++ Programming]
long long llabs(long long x);
long long int llabs(long long int x);
llabs() 函数采用long long
或long long int
类型的单个参数,并返回相同类型的值。
x
:一个long long或long long int数据,其绝对值被返回。
llabs() 函数返回x的绝对值,即| x |。
#include
#include
using namespace std;
int main()
{
long long x,y;
x = -79182028361LL;
y = 129301730192LL;
cout << "llabs(" << x << ") = |" << x << "| = " << llabs(x) << endl;
cout << "llabs(" << y << ") = |" << y << "| = " << llabs(y) << endl;
return 0;
}
运行该程序时,输出为:
llabs(-79182028361) = |-79182028361| = 79182028361
llabs(129301730192) = |129301730192| = 129301730192