#1562. 信息素养大赛模拟卷
信息素养大赛模拟卷
单项选择题,每个 分。
- 执行以下程序段,输入 ,输出是()
int x;
cin >> x;
cout << x + 2;
{{ select(1) }}
- 在
C++
中,输入指令是()
{{ select(2) }}
cout
cin
clog
int
- 假设有两个城市:城市 和城市 。每个城市的温度都在 之间,当且仅当只有一个城市的温度低于 时,输出 ,也就是说,如果 的温度低于 且城市 大于等于 ;或者如果城市 的温度大于等于 而 小于 ,则输出 ,否则输出 ,请你补全下面代码的两处空缺。
#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
if (__)
{
if (__)
{
cout << 1;
return 0;
}
}
if (a >= 0)
{
if (b < 0)
{
cout << 1;
return 0;
}
}
cout << 0;
return 0;
}
{{ select(3) }}
a < 0 b >= 0
a > 0 b <= 0
a >= 0 b >= 0
a < 0 b < 0
- 在
C++
中,表示布尔数据类型的关键字是()
{{ select(4) }}
int
bool
double
string
- 完全数指的是一个数恰好等于除它本身之外的所有因数之和,例如: 的因数有 ,除去 以外的因数之和为 ,因此 是完全数。编写程序,按从小到大的顺序寻找 之间的完全数,输出第 个完全数,,补全三处代码。
#include <iostream>
using namespace std;
int main()
{
int n, sum = 0, num = 0;
cin >> n;
for (int i = 1; i < 10000; i++)
{
int a = i;
sum = 0;
for (int j = 1; j < a; j++)
{
if (a % j == 0)
{
___
}
}
if (___)
{
num++;
}
if (num == n)
{
cout << a;
____
}
}
return 0;
}
{{ select(5) }}
sum += i; sum == a continue;
sum += j; sum == a break;
sum += j sum !+= a continue;
sum += i; sum == a break;
- 以下可以作为变量名的是 ( )。
{{ select(6) }}
cnt_1
1_cnt
cnt1_#
@cnt
C++
中有很多数据类型,以下可以定义存储浮点型变量的关键字是()
{{ select(7) }}
int
double
char
long long
- 如果我们想在终端输出变量 的值,正确的代码是() {{ select(8) }}
cin >> x
cin << x
cout << x
cout >> x
- 执行以下代码段,变量 和 的值分别是()
int x = 7;
int y = x / 2 * 3;
{{ select(9) }}
x = 7, y = 10.5
x = 7, y = 10
x = 7, y = 12
x = 7, y = 9
- 执行以下代码,输出的结果是()
int x = 5, y = 3;
cout << (x > y);
{{ select(10) }}
true
false
1
2
- 在
C++
中,如果用两个int
类型的变量length
和width
分别表示长方形的长和宽,则可以用来计算长方形面积的表达式是()。
{{ select(11) }}
length * width
length + width
(length + width) / 2
length * 2 + width * 2
- 数字直角三角形:给出 ,输出一个直角边长为 的数字直角三角形,所有数字都是 位组成的,如果没有 位则加上前导 ,试补全 ① 和 ② 的代码。
例如当 的数字三角形如下所示
01
0203
040506
07080910
1112131415
#include <iostream>
using namespace std;
int main()
{
int n, cnt = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 1;__①__; j++)
{
cnt++;
if (__②__)
{
cout << 0;
}
cout << cnt;
}
cout << endl;
}
return 0;
}
{{ select(12) }}
j <= n cnt < 10
j <= n cnt > 10
j <= i cnt < 10
j <= i cnt > 10
- 编写程序,计算区间 之间的所有整数( ),数字 () 共出现的次数。补全 ①、② 和 ③ 处的代 码。
例如: 到 中,即 中,数字 出现了 次。
#include <iostream>
using namespace std;
int main()
{
int n, x, cnt = 0;
cin >> n >> x;
for (int i = 100; i <= n; i++)
{
_①_
int g, s, b;
g = a % 10;
__②__
__③__
if (g == x)
{
cnt++;
}
if (s == x)
{
cnt++;
}
if (b == x)
{
cnt++;
}
}
cout << cnt;
return 0;
}
{{ select(13) }}
int a = i; s = a / 10 % 10; b = a / 100;
int g = i; s = g % 10; b = g % 100;
int cnt = i; s = cnt % 10; b = cnt / 100;
int a = b; s = a / 10; b = a % 100;
- 运行下列程序段,输出的结果是()。
int n = 572765;
cout << n / 10 % 10;
{{ select(14) }}
- 下列关于C++ 语言中变量的叙述,不正确的是() {{ select(15) }}
- 变量定义时可以不初始化
- 变量被赋值之后的类型不变
- 变量没有定义也能够使用
- 变量名必须是合法的标识符
判断题,每个 分。
- 在
C++
中,变量声明后,如果不初始化,其值是确定的。
{{ select(16) }}
- 正确
- 错误
- 在
C++
中,==
是赋值运算符。
{{ select(17) }}
- 正确
- 错误
- 在
C++
中,整型int
可以用来存储小数。
{{ select(18) }}
- 正确
- 错误
- 在
C++
中,所有变量都必须在使用前声明其数据类型。
{{ select(19) }}
- 正确
- 错误
- 在
C++
中,变量名可以以字母或下划线开头。
{{ select(20) }}
- 正确
- 错误
相关
在下列比赛中: