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

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

  1. 在C++中,下列标识符不合法的是 {{ select(1) }}
  • 123
  • A6
  • _123
  • paul

执行下面C++代码后输出是

#include <iostream>

using namespace std;
int main()
{
 int cnt = 0;
 for (int i = 10; i > 3; i -= 3)
 {
  cnt += i; 
 } 
 cout << cnt;
 return 0;
}

{{ select(2) }}

  • 3
  • 27
  • 49
  • 21
  1. C++表达式(4*(11+12)/4)的计算结果为

{{ select(3) }}

  • 47
  • 20
  • 23
  • 56
  1. 下列关于C++语言变量的叙述,有误的是 {{ multiselect(4) }}
  • 变量可以没有定义
  • 对一个没有定义的变量赋值,相当于定义了一个新变量
  • 执行赋值语句后,变量的类型可能会变化
  • 执行赋值语句后,变量的值可能不会变化
  1. 如果a为int类型的变量,则执行a %= 4;之后,a的值可能会是 {{ multiselect(5) }}
  • 1
  • 2
  • 4
  • 5
  1. 假设平行四边形的两条边的长度分别为a和b,则可以表示平行四边形的周长的是 {{ multiselect(6) }}
  • cout << a + a + b + b;
  • cout << a * 2 + b * 2;
  • cout << (a + b) * 2;
  • cout << a * 2 + b + b;

下列程序可能的输出结果有哪些()

#include <iostream>
using namespace std;
int main()
{ 
 for (int i = 1; i <= 1000; i++)
 {
  int s = 0;
  for (int j = 1; j < i; j++)
  {
   if (i % j == 0)
   {
    s += j; 
   } 
  } 
  if (i == s)
  {
   cout << s << endl;
  }
 } 
 return 0;
}

{{ multiselect(7) }}

  • 5
  • 6
  • 28
  • 496

下面程序输入的值为多少的时候,输出结果大于等于4()

#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++;

  }

 }

 cout << cnt;

 return 0;

}

{{ multiselect(8) }}

  • 12
  • 24
  • 2
  • 3

若使以下程序输出1 3 5 7,则①处应该补全的代码为

#include <iostream>

using namespace std;


int main()

{

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

{

    if (\_\_①\_\_)

    {

        cout << i << " ";

    }

}

return 0;

}

{{ multiselect(9) }}

  • i % 2 == 0
  • i % 2 == 1
  • i % 2 != 1
  • i % 2 != 0

下列说法正确的是( )

{{ multiselect(10) }}

  • 在C++语言中,*可以计算两个数相乘的结果。
  • 在C++语言中,||表示逻辑或,两个操作数中有一个为真时,整体即为真。
  • 在C++语言中,变量的命名可以用字母或者下划线作为开头。
  • 在C++语言中,顺序结构是指按照从上到下、从左到右依次执行的程序结构。