Translations of this page?:

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;

C++ 同样提供了下列的重载形式:

    #include <cstdlib>
    long abs( long num ); // same as labs()
 
    #include <cmath>
    // the following are synonyms for fabs()
    float abs( float num );
    double abs( double num );
    long double abs( long double num );

相关主题: fabs, labs

 
• • • SitemapRecent changesRSScc