abs全稱是什么?
c++ abs()干什么用的?
拉風(fēng)的咖菲貓
2018-07-29 17:17:19
TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
abs全稱是 a function returns the absolute value of its parameter.
這是一個(gè)函數(shù),返回它的參數(shù)(整型)的絕對值。
abs 是 absolute value (絕對值)縮寫。c++ 中的一個(gè)數(shù)學(xué)函數(shù),計(jì)算整型量的絕對值。要頭文件 #include <cmath> 或 #include <math.h>
算例:
int x=16, y= -6;
cout << abs(x) << endl;
cout << abs(y) << endl;
輸出:
16
6
浮點(diǎn)數(shù)的絕對值用 fabs 函數(shù)。
舉報(bào)