A. C++ 中级组客观题

    客观题

C++ 中级组客观题

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

一、单项选择题

  1. 下列选项中,符合C++变量命名规则的是? {{ select(1) }}
  • 321_x
  • int
  • student_age
  • my-name
  1. 下列关于cout输出语句的用法,错误的是? {{ select(2) }}
  • cout<<"Hello World"<<endl;
  • cout<<123<<" "<<456;
  • cout>>"C++";
  • cout<<'A'<<endl;
  1. 执行以下代码,输出结果是?
#include<iostream>
using namespace std;
int main(){
    int a = 80, b=70;
    if(a < b)
       a = b;
    b = a;
    cout << a << " " << b;
    return 0;
}

{{ select(3) }}

  • 80 70
  • 70 70
  • 80 80
  • 70 80
  1. 已知int a=8, b=5,下列逻辑运算结果为真的是? {{ select(4) }}
  • a<b || a!=b
  • a>b && a==b
  • !(a>b)
  • a<b && a!=b
  1. 以下for循环的执行次数是?
for(int i=1; i<=10; i+=2){
    cout<<i<<" ";
}

{{ select(5) }}

  • 5
  • 6
  • 9
  • 10
  1. 下列关于while循环和do-while循环的说法,正确的是? {{ select(6) }}
  • while循环至少执行一次循环体
  • do-while循环先判断条件,再执行循环体
  • 循环条件不成立时,while循环一次都不执行
  • do-while循环的循环体可能一次都不执行
  1. 下列数组的定义和初始化,正确的是? {{ select(7) }}
  • int a[5]={1,2,3,4,5,6};
  • int x=4; int a[x]={1,2,3,4};
  • int a[]={77,80,91,62,85};
  • int a[3]; a={1,2,3};
  1. 执行以下代码,输出结果是?
#include<iostream>
using namespace std;
int main(){
    char str[5]={'a','b','c','d',0};
    str[2]='\0';
    cout<<str;
    return 0;
}

{{ select(8) }}

  • ab
  • abc
  • abcd
  • 编译报错
  1. 下列关于setw()和setfill()函数的说法,错误的是? {{ select(9) }}
  • 使用这两个函数需要包含头文件
  • setw()只对紧跟其后的输出内容起作用
  • setfill()设置的填充字符只对当前行有效
  • 输出内容宽度大于setw()设置的宽度时,内容原样输出
  1. 使用printf输出double类型变量时,应使用的占位符是? {{ select(10) }}
  • %d
  • %f
  • %lf
  • %lld
  1. 执行以下代码,输出结果是?
#include<iostream>
using namespace std;
int main(){
    int i = 5;
    cout << i++ << endl;
    cout << ++i << endl;
    return 0;
}

{{ select(11) }}

  • 5 6
  • 5 7
  • 6 6
  • 6 7
  1. 下列关于switch语句的说法,正确的是? {{ select(12) }}
  • switch括号内的表达式可以是浮点型
  • case后面可以跟变量或表达式
  • 每个case分支必须以break结尾,否则编译报错
  • default语句用于处理所有case都不匹配的情况
  1. 表达式3 + 2.5f + 'A' + 1.0的最终结果类型是? {{ select(13) }}
  • int
  • float
  • double
  • char
  1. 下列关于float和double类型的说法,正确的是? {{ select(14) }}
  • float类型的有效数字是16位
  • double类型的精度比float类型更高
  • 编程中保存小数优先使用float类型
  • float类型字面常量的默认写法是3.14
  1. 下列关于break和continue语句的说法,正确的是? {{ select(15) }}
  • continue用于终止整个循环
  • break用于跳过本次循环,进入下一次循环
  • 在switch语句中可以使用break终止分支执行
  • 在for循环中,break和continue的作用完全相同
  1. 执行以下代码,输出结果是?
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    char s[] = "hello world";
    cout << strlen(s);
    return 0;
}

{{ select(16) }}

  • 10
  • 11
  • 12
  • 13
  1. 下列运算符中,优先级最高的是? {{ select(17) }}
  • &&
  • ==
  • +
  • !
  1. 下列场景中,必须使用long long类型而非int类型的是? {{ select(18) }}
  • 存储100以内的学生成绩
  • 存储10000以内的商品价格
  • 存储角谷猜想中10^9的输入数值
  • 存储100以内的循环次数
  1. 执行以下代码,输入7,输出结果是?
#include<iostream>
using namespace std;
int main(){
    int a;
    cin >> a;
    if(a > 3) cout << "low";
    else if(a > 1) cout << "mini";
    else cout << "medium";
    return 0;
}

{{ select(19) }}

  • low
  • mini
  • medium
  • 无输出
  1. 下列关于字符串输入的说法,正确的是? {{ select(20) }}
  • cin >> s可以接收包含空格的字符串
  • cin.getline(s, n)可以接收包含空格的字符串
  • cin.getline()不需要指定输入字符串的长度
  • cin和cin.getline()遇到回车都不会结束输入
  1. 执行strcmp("abcd", "abcf"),返回值的结果是? {{ select(21) }}
  • 大于0
  • 小于0
  • 等于0
  • 不确定
  1. 想要倒序输出数组a[5]={1,2,3,4,5}的所有元素,下列for循环写法正确的是? {{ select(22) }}
  • for(int i=0; i<5; i++) cout<<a[i]<<" ";
  • for(int i=5; i>0; i--) cout<<a[i]<<" ";
  • for(int i=4; i>=0; i--) cout<<a[i]<<" ";
  • for(int i=4; i>0; i--) cout<<a[i]<<" ";
  1. 下列表达式中,能正确判断闰年的是? {{ select(23) }}
  • n%4 == 0 && n%100 != 0 || n%400 == 0
  • n%4 == 0 || n%100 != 0 && n%400 == 0
  • n%4 == 0 && n%400 == 0 || n%100 != 0
  • n%400 == 0 && n%4 == 0 || n%100 != 0
  1. 下列关于string类型的操作,错误的是? {{ select(24) }}
  • string s1 = "hello", s2 = "world"; string s3 = s1 + s2;
  • string s = "hello"; s[0] = 'H';
  • string s1 = "abc", s2 = "abd"; if(s1 > s2) cout<<"yes";
  • string s = "hello"; s2 = "hi";
  1. 执行以下代码,输入12 7 9,输出结果是?
#include<iostream>
using namespace std;
int main(){
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){ t=a; a=b; b=t; }
    if(a>c){ t=a; a=c; c=t; }
    if(b>c){ t=b; b=c; c=t; }
    cout << a << " " << b << " " << c;
    return 0;
}

{{ select(25) }}

  • 12 7 9
  • 7 9 12
  • 12 9 7
  • 9 7 12

二、判断题

  1. 变量名x321_符合C++命名规则。 {{ select(26) }}
  • 正确
  • 错误
  1. if和else默认只执行后面的一行语句,多行语句需要用{}包裹成复合语句。 {{ select(27) }}
  • 正确
  • 错误
  1. if语句不可以嵌套使用。 {{ select(28) }}
  • 正确
  • 错误
  1. else语句不是必须的,可以只写if语句。 {{ select(29) }}
  • 正确
  • 错误
  1. 循环次数已知时,优先使用while循环。 {{ select(30) }}
  • 正确
  • 错误
  1. do-while循环的循环体至少会执行一次。 {{ select(31) }}
  • 正确
  • 错误
  1. strlen()属于<iostream>头文件中的函数。 {{ select(32) }}
  • 正确
  • 错误
  1. switch括号内的表达式结果可以为浮点型。 {{ select(33) }}
  • 正确
  • 错误
  1. 去掉case后的break,不会继续执行后续case的语句。 {{ select(34) }}
  • 正确
  • 错误
  1. break可以终止整个循环的执行。 {{ select(35) }}
  • 正确
  • 错误

C++中级组(2026.5科技节)

未参加
状态
已结束
规则
OI
题目
3
开始于
2026-5-22 19:45
结束于
2026-5-26 23:45
持续时间
100 小时
主持人
参赛人数
28