#4650. C++内置常用函数练习题

C++内置常用函数练习题

一、基础知识填空题(共6题)

  1. 计算整数绝对值的函数是( )。

{{ input(1) }}


  1. 计算浮点数绝对值的函数是( )。

{{ input(2) }}


  1. 计算数次幂的函数是( )。

{{ input(3) }}


  1. 求平方根的函数是( )。

{{ input(4) }}


  1. C++中用于计算 exe^x(自然常数e的x次方)的数学函数是( )?

通俗解释:求自然指数运算 exe^x 用哪个函数。

{{ input(5) }}


  1. C++中用来生成随机整数的基础函数是( )?

通俗解释:想要程序随机变出数字,基础函数名称。

{{ input(6) }}


二、函数应用填空题(共5题)

  1. 补全代码输出 -5 的绝对值:
int num = -5;
cout << ( ? )(num) << endl;

{{ input(7) }}


  1. 补全代码计算 2^3:
double base = 2, exponent = 3;
cout << ( ? )(base, exponent) << endl;

{{ input(8) }}


  1. 补全代码输出 3.8 向上取整结果:
double num = 3.8;
cout << ( ? )(num) << endl;

{{ input(9) }}


  1. 补全代码输出 17.5 % 5.2 的余数:
double a = 17.5, b = 5.2;
cout << ( ? )(a, b) << endl;

{{ input(10) }}


  1. 补全代码设置随机种子:
( ? )((unsigned)time(0));

{{ input(11) }}


三、单选题(共5题)

  1. 下列函数中用于向上取整的是()

{{ select(12) }}

  • ceil
  • floor
  • round
  • trunc

  1. 下列函数中用于向下取整的是()

{{ select(13) }}

  • ceil
  • floor
  • round
  • trunc

  1. 下列函数中用于计算平方根的是()

{{ select(14) }}

  • pow
  • exp
  • sqrt
  • abs

  1. 下列函数中用于求两个数较大值的是()

{{ select(15) }}

  • min
  • max
  • sort
  • find

  1. 下列函数中用于计算浮点数余数的是()

{{ select(16) }}

  • mod
  • rem
  • fmod
  • rand