#4268. C++青科赛小学组(2)--选择题

C++青科赛小学组(2)--选择题

  1. C++ 中下列哪个标识符是不合法的 {{ select(1) }}
  • func_2
  • 2nd_func
  • varName
  • _123abc
#include <iostream>

using namespace std;

int main()

{

int cnt = 1;

for (int i = 1; i <= 3; i++)

{

    cnt \*= i;

}

cout << cnt;

return 0;
}

在 C++ 中,执行以下代码后,输出的是 {{ select(2) }}

  • 3
  • 6
  • 9
  • 12

C++表达式8 + 2 * (5 - 3) % 6的值是{{ select(3) }}

  • 8
  • 10
  • 12
  • 14
  1. 关于C++中的循环结构,下列说法正确的是 {{ multiselect(4) }}
  • while循环可以实现代码的重复执行。
  • do-while循环至少执行一次循环体。
  • for循环可以通过递增表达式控制循环次数。
  • 循环结构不能嵌套使用。
  1. 下面表达式中,结果为7的有哪些 {{ multiselect(5) }}
  • cout << 2 + 5;
  • cout << 3 * 4;
  • cout << 7 - 0;
  • cout << 14 / 8;
  1. 下列说法正确的是{{ multiselect(6) }}
  • 假设圆形的半径为r,在C++中,可以通过cout << 2 * 3.14 * r;语句来输出圆形的周长
  • 假设圆形的半径为r,在C++中,可以通过cout << 3.14 * r * r;语句来输出圆形的面积
  • 假设直角三角形的两个直角边长度为a和b,在C++中,可以通过cout << a * b * 0.5;语句来输出直角三角形的面积
  • 假设三角形的底和高长度为a和b,在C++中,可以通过cout << a * b * 0.5;语句来输出三角形的面积
  1. 下列程序可能的输出结果有哪些
#include<iostream>

using namespace std;

int main()

{

for (int i = 100; i <= 400; i++)

{

int b = i / 100;

int s = i / 10 % 10;

int g = i % 10;

if (b \* b \* b + s \* s \* s + g \* g \* g == i)

{

cout << i << endl;

}

}

return 0;

}

{{ multiselect(7) }}

  • 153
  • 370
  • 371
  • 407
  1. 下面程序输入的值为多少的时候,输出结果为no
#include <iostream>

using namespace std;

int main()

{

int n, cnt = 0;

cin >> n;

for (int i = 1; i <= n; i++)

{

if (n % i == 0)

{

cnt++;

}

}

if (cnt == 2)

{

cout << "yes";

}

else

{

cout << "no";

}

return 0;

}

{{ multiselect(8) }}

  • 8
  • 9
  • 13
  • 17
  1. 在下列代码的横线处填写(),可以使得输出是2 5 8 11。
for (int i = 2; i <= 11; ____)//在此处填入代码

{

cout << i << " ";
}

{{ multiselect(9) }}

  • i++
  • i = i + 3
  • i + 3
  • i +=3
  1. 在C++语言中,int类型的变量x、y、z的值分别为3、5、8,以下表达式的值为假的是() {{ multiselect(10) }}
  • x > y || x > z
  • x != z - y
  • z > y + x
  • x > y && y < z