C++ 编程/代码/标准 C 库/函数/abs
外观
语法 |
#include <cstdlib>
int abs( int num );
|
abs() 函数返回 num 的绝对值。例如
int magic_number = 10;
cout << "Enter a guess: ";
cin >> x;
cout << "Your guess was " << abs( magic_number - x ) << " away from the magic number." << endl;