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