#1011. U1单元测-客观题

U1单元测-客观题

  1. 查看以下代码,问最终 a 的值是多少
int a = 1, b = 2;
a += b;

{{ select(1) }}

  • 1
  • 2
  • 3
  • 4

  1. 查看以下代码,保留两位小数的输出是
double x = 1.0;

{{ select(2) }}

  • printf("%.2f", x);
  • printf("%2d", x);
  • printf("%02d", x);
  • cout << x;

  1. 给出以下代码,输出的是
cout << (1 > 2 ? 2 : 3);

{{ select(3) }}

  • 1
  • 2
  • 3
  • 4

  1. 以下哪个选项符合 c++ 命名规则?

{{ select(4) }}

  • int 0a = 3;
  • int _ = 3;
  • int a b = 3;
  • int ab\n = 3;

  1. 26D26_D 转换为二进制是下面哪个选项?

{{ select(5) }}

  • 11010B11010_B
  • 11011B11011_B
  • 11111B11111_B
  • 1010B1010_B

  1. 15D15_D 的值和下面的哪个选项一样?

{{ select(6) }}

  • 1101B1101_B
  • BHB_H
  • 13D13_D
  • 17O17_O

  1. 程序阅读1
#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    switch (n){
        case 1:
            cout << "1" << ' ';
            break;
        case 2:
            cout << "2" << ' ';
            break;
        case 3:
            cout << "3" << ' ';
        case 4:
            cout << "4" << ' ';
        default:
            cout << "5" << ' ';
    }

    return 0;
}

7.1 输入 n 为 2,则输出结果为 ?

{{ select(7) }}

  • 1
  • 2 3 4 5
  • 3 4 5
  • 2

7.2 输入 n 为 4,则输出结果为 ?

{{ select(8) }}

  • 4
  • 4 5
  • 5
  • 4 3

  1. 阅读程序2

代码1

#include <iostream>
using namespace std;

int main(){
    int sum = 0;
    for (int i = 1; i <= 5; i++)
    {
        if (i == 3)
        {
            continue;
        }
        sum += i;
    }
    cout << sum;
    return 0;
}

代码2

#include <iostream>
using namespace std;

int main(){
    int sum = 0;
    for (int i = 1; i <= 5; i++)
    {
        if (i == 3)
        {
            break;
        }
        sum += i;
    }
    cout << sum;
    return 0;
}

以上两段代码的输出结果为 ?

{{ select(9) }}

  • 3 3
  • 3 12
  • 12 3
  • 12 12