#G051. GESP level2 常用数学函数(绝对值函数、平方根函数、max函数、min函数)模拟一

GESP level2 常用数学函数(绝对值函数、平方根函数、max函数、min函数)模拟一

GESP level2 - 常用数学函数(绝对值函数、平方根函数、max函数、min函数)模拟一

  1. C++中,若要计算浮点数-3.14的绝对值,应使用以下哪个函数( ) {{ select(1) }}
  • abs()
  • fabs()
  • pow()
  • min()
  1. 执行以下代码后,输出结果是( )
    #include 
    #include 
    using namespace std;
    int main(){
    double num = 64.0;
    cout << sqrt(num);
    return 0;
    }
    
    {{ select(2) }}
  • 8
  • 8.0
  • 4096
  • 0
  1. 在C++中,以下代码执行后的输出结果是( )
    #include 
    #include 
    using namespace std;
    int main(){
    int a = 5, b = 15;
    cout << max(a, b);
    return 0;
    }
    
    {{ select(3) }}
  • 5
  • 15
  • 20
  • 75
  1. 下列关于pow函数的说法,正确的是( ) {{ select(4) }}
  • pow(x, y)用于计算x的y次方
  • pow函数只能计算整数次方
  • 使用pow函数无需包含头文件
  • pow(2, 3)的返回值是5
  1. 执行以下代码,输出结果是( )
    #include 
    #include 
    using namespace std;
    int main(){
    int num = -16;
    cout << abs(num);
    return 0;
    }
    
    {{ select(5) }}
  • -16
  • 16
  • 0
  • 16.0
  1. 以下代码执行后,输出的结果是( )
    #include 
    #include 
    using namespace std;
    int main(){
    double x = 7.8, y = 4.2;
    cout << min(x, y);
    return 0;
    }
    
    {{ select(6) }}
  • 7.8
  • 4.2
  • 3.6
  • 12.0
  1. 在计算圆面积的代码中,需要使用pow函数计算半径的平方,以下代码横线处应填入( )
    #include 
    #include 
    using namespace std;
    int main(){
    double r = 5.0, area;
    area = 3.14 * ______;
    cout << area;
    return 0;
    }
    
    {{ select(7) }}
  • r * 2
  • pow(r, 2)
  • sqrt(r)
  • pow(2, r)
  1. 执行下列代码,输出结果是( )
    #include 
    #include 
    using namespace std;
    int main(){
    int a = -9, b = 36;
    cout << abs(a) + sqrt(b);
    return 0;
    }
    
    {{ select(8) }}
  • 3
  • 9
  • 15
  • 27
  1. C++中,若要计算3的4次方,应使用以下哪个表达式( ) {{ select(9) }}
  • 3 * 4
  • pow(3, 4)
  • sqrt(3*4)
  • max(3, 4)
  1. 执行以下代码后,输出结果是( )
    #include 
    #include 
    using namespace std;
    int main(){
    double num = 16.0;
    cout << pow(num, 0.5);
    return 0;
    }
    
    {{ select(10) }}
  • 4
  • 8
  • 256
  • 0
  1. 下列关于数学函数的说法,错误的是( ) {{ select(11) }}
  • sqrt(0)的返回值是0
  • abs(-0)的返回值是0
  • pow(2, -1)的返回值是0.5
  • min(5, 5)会导致程序报错
  1. 执行下列代码,输出结果是( )
    #include 
    #include 
    #include 
    using namespace std;
    int main(){
    int a = -4, b = 9;
    cout << fabs(a) + sqrt(b);
    return 0;
    }
    
    {{ select(12) }}
  • 1
  • 5
  • 7
  • 13