#A1. 信息素养1

信息素养1

1.以下函数,当调用语句为 long p = fun(3, 3); 时,返回的 p 值是?

long fun(int x, int y) {  
    int i;  
    long p = 1;  
    for (i = 0; i < y; i++) p *= x;  
    return p;  
}

{{ select(1) }}

  • 3
  • 9
  • 27
  • 71

2.下列事件中的必然事件是?

{{ select(2) }}

  • 小A同学参加下周的数学考试,一定能考100分
  • 射击运动员射靶10次,必定能有1次正中靶心
  • 打开电视机,正好在播放新闻联播
  • 口袋中有2个红球和1个白球,从中摸出2个球,必定至少有1个红球

3.二进制数 0.101 转换为十进制数为?

{{ select(3) }}

  • 0.5
  • 0.625
  • 0.2
  • 0.75

4.有A、B、C、D、E五个同学站成一排,如果A和B必须站在一起,则有多少种不同的排法?

{{ select(4) }}

  • 24
  • 48
  • 60
  • 120

5.在Dev C++中,C++源程序文件的默认扩展名为( ),可执行文件的默认扩展名为( )。

{{ select(5) }}

  • .c, .exe
  • .cpp, .exe
  • .exe, .cpp
  • .exe, .c

6.以下函数定义中,当 n 传入10时,返回值应为?

int func(int n) {  
    if (n == 1) return 1;  
    else return func(n - 1) + n;  
}

{{ select(6) }}

  • 45
  • 55
  • 66
  • 1

7.下面哪种循环语句在条件判断之前至少会执行一次循环体?

{{ select(7) }}

  • for
  • while
  • do-while
  • switch

8.填写以下程序,使其输出 "Hello, world!",横线处应填写?

#include <iostream>  
using namespace std;  
int main() {  
    ______ << "Hello, world!" << endl;  
    return 0;  
}

{{ select(8) }}

  • cin
  • cout
  • std::cin
  • std::cout

9.以下两个函数 fun1() 和 fun2() 定义如下,主函数中调用 int x=1 , x = fun1(x); 后,x 的值为?

int fun1(int x) {  
    x++;  
    fun2(x);  
    return x;  
}  
void fun2(int x) { x++; }

{{ select(9) }}

  • 1
  • 2
  • 3
  • 4

10.以下程序段运行后,输出应为?

int a, b;  
for (a = 1, b = 1; a <= 100; a++) {  
    if (b > 20) break;  
    if (b % 4 == 1) {  
        b += 4;  
        continue;  
    }  
    b -= 5;  
}  
cout << a;

{{ select(10) }}

  • 100
  • 20
  • 9
  • 6

11.以下程序段运行后,输入 ABCdef,输出应为?

char ch;  
while ((ch = getchar()) != '\n') {  
    if (ch >= 'A' && ch <= 'Z') ch += 32;  
    else if (ch >= 'a' && ch <= 'z') ch -= 32;  
    cout << ch;  
}

{{ select(11) }}

  • ABCdef
  • abcdef
  • ABCDEF
  • abcDEF

12.以下代码输出 num 的顺序是?

int num = 10;  
cout << num++ << endl;  
cout << ++num << endl;  
cout << num-- << endl;  
cout << --num << endl;

{{ select(12) }}

  • 10 12 12 10
  • 10 12 11 9
  • 11 12 12 10
  • 11 12 11 9