一、选择题(每题 2 分,共 30 分)
-
中国的国家顶级域名是()A. .cnB. .chC. .chnD. .china
-
二进制数 11 1011 1001 0111 和 01 0110 1110 1011 进行按位与运算的结果是()A. 01 0010 1000 1011B. 01 0010 1001 0011C. 01 0010 1000 0001D. 01 0010 1000 0011
-
一个 32 位整型变量占用()个字节A. 32B. 128C. 4D. 8
-
若有如下程序段,其中 s、a、b、c 均已定义为整型变量,且 a、c 均已赋值(c 大于 0)s = a;for (b = 1; b <= c; b++) s = s - 1;则与上述程序段功能等价的赋值语句是()A. s = a - c;B. s = a - b;C. s = s - c;D. s = b - c;
-
设有 100 个已排好序的数据元素,采用折半查找时,最大比较次数为()A. 7B. 10C. 6D. 8
-
链表不具有的特点是()A. 插入删除不需要移动元素B. 不必事先估计存储空间C. 所需空间与线性表长度成正比D. 可随机访问任一元素
-
把 8 个同样的球放在 5 个同样的袋子里,允许有的袋子空着不放,问共有多少种不同的分法?()A. 22B. 24C. 18D. 20
-
一棵二叉树如右图所示,若采用顺序存储结构,即用一维数组元素存储该二叉树中的结点(根结点的下标为 1,若某结点的下标为 i,则其左孩子位于下标 2i 处、右孩子位于下标 2i+1 处),则该数组的最大下标至少为()A. 6B. 10C. 15D. 12
-
100 以内最大的素数是()A. 89B. 97C. 91D. 93
-
319 和 377 的最大公约数是()A. 27B. 33C. 29D. 31
-
新学期开学了,小胖想减肥,健身教练给小胖制定了两个训练方案方案一:每次连续跑 3 公里可以消耗 300 千卡(耗时半小时);方案二:每次连续跑 5 公里可以消耗 600 千卡(耗时 1 小时)。小胖每周周一到周四能抽出半小时跑步,周五到周日能抽出一小时跑步。另外,教练建议小胖每周最多跑 21 公里,否则会损伤膝盖。请问如果小胖想严格执行教练的训练方案,并且不想损伤膝盖,每周最多通过跑步消耗多少千卡?()A. 3000B. 2500C. 2400D. 2520
-
一副纸牌除掉大小王有 52 张牌,四种花色,每种花色 13 张假设从这 52 张牌中随机抽取 13 张纸牌,则至少()张牌的花色一致A. 4B. 2C. 3D. 5
-
一些数字可以颠倒过来看,例如 0,1,8 颠倒过来还是本身,6 颠倒过来是 9,9 颠倒过来看还是 6,其他数字颠倒过来都不构成数字类似的,一些多位数也可以颠倒过来看,比如 106 颠倒过来是 901。假设某个城市的车牌只由 5 位数字组成,每一位都可以取 0 到 9请问这个城市最多有多少个车牌倒过来恰好还是原来的车牌?()A. 60B. 125C. 75D. 100
-
假设一棵二叉树的后序遍历序列为 DGJHEBIFCA,中序遍历序列为 DBGEHJACIF,则其前序遍历序列为()A. ABCDEFGHIJB. ABDEGHJCFIC. ABDEGJHCFID. ABDEGHJFIC
-
以下哪个奖项是计算机科学领域的最高奖?()A. 图灵奖B. 鲁班奖C. 诺贝尔奖D. 普利策奖
二、阅读程序(共 40 分)
第 16 题
c++
#include <cstdio>
#include <cstring>
using namespace std;
char st[100];
int main() {
scanf("%s", st);
int n = strlen(st);
for (int i = 1; i <= n; ++i) {
if (n % i == 0) {
char c = st[i - 1];
if (c >= 'a')
st[i - 1] = c - 'a' + 'A';
}
}
printf("%s", st);
return 0;
}
判断题
-
输入的字符串只能由小写字母或大写字母组成。()A. 正确B. 错误
-
若将第 8 行的 i = 1 改为 i = 0,程序运行时会发生错误。()A. 正确B. 错误
-
若将第 8 行的 i <= n 改为 i * i <= n,程序运行结果不会改变。()A. 正确B. 错误
-
若输入的字符串全部由大写字母组成,那么输出的字符串就跟输入的字符串一样。()A. 正确B. 错误
选择题
-
若输入的字符串长度为 18,那么输入的字符串跟输出的字符串相比,至多有()个字符不同A. 18B. 6C. 10D. 1
-
若输入的字符串长度为(),那么输入的字符串跟输出的字符串相比,至多有 36 个字符不同A. 36B. 100000C. 1D. 128
第 17 题
c++
#include<cstdio>
using namespace std;
int n, m;
int a[100], b[100];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
a[i] = b[i] = 0;
for (int i = 1; i <= m; ++i) {
int x, y;
scanf("%d%d", &x, &y);
if (a[x] < y && b[y] < x) {
if (a[x] > 0)
b[a[x]] = 0;
if (b[y] > 0)
a[b[y]] = 0;
a[x] = y;
b[y] = x;
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] == 0)
++ans;
if (b[i] == 0)
++ans;
}
printf("%d", ans);
return 0;
}
判断题
-
当 m>0 时,输出的值一定小于 2n。()A. 正确B. 错误
-
执行完第 27 行的 ++ans 时,ans 一定是偶数。()A. 正确B. 错误
-
a [i] 和 b [i] 不可能同时大于 0。()A. 正确B. 错误
-
若程序执行到第 13 行时,x 总是小于 y,那么第 15 行不会被执行。()A. 正确B. 错误
选择题
-
若 m 个 x 两两不同,且 m 个 y 两两不同,则输出的值为()A. 2n−2mB. 2n+2C. 2n−2D. 2n
-
若 m 个 x 两两不同,且 m 个 y 都相等,则输出的值为()A. 2n−2B. 2nC. 2mD. 2n−2m
第 18 题
c++
#include <iostream>
using namespace std;
const int maxn = 10000;
int n;
int a[maxn];
int b[maxn];
int f(int l, int r, int depth) {
if (l > r)
return 0;
int min = maxn, mink;
for (int i = l; i <= r; ++i) {
if (min > a[i]) {
min = a[i];
mink = i;
}
}
int lres = f(l, mink - 1, depth + 1);
int rres = f(mink + 1, r, depth + 1);
return lres + rres + depth * b[mink];
}
int main() {
cin >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n; ++i)
cin >> b[i];
cout << f(0, n - 1, 1) << endl;
return 0;
}
判断题
-
如果 a 数组有重复的数字,则程序运行时会发生错误。()A. 正确B. 错误
-
如果 b 数组全为 0,则输出为 0。()A. 正确B. 错误
选择题
-
当 n=100 时,最坏情况下,与第 12 行的比较运算执行的次数最接近的是:()A. 5000B. 600C. 6D. 100
-
当 n=100 时,最好情况下,与第 12 行的比较运算执行的次数最接近的是:()A. 100B. 6C. 5000D. 600
-
当 n=10 时,若 b 数组满足,对任意 0≤i<n,都有 b [i] = i + 1,那么输出最大为()A. 386B. 383C. 384D. 385
-
当 n=100 时,若 b 数组满足,对任意 0≤i<n,都有 b [i]=1,那么输出最小为()A. 582B. 580C. 579D. 581
三、程序补全(共 30 分)
第 19 题
c++
#include <cstdio>
using namespace std;
int n;
const int max_size = 1 << 10;
int res[max_size][max_size];
void recursive(int x, int y, int n, int t) {
if (n == 0) {
res[x][y] = ①;
return;
}
int step = 1 << (n - 1);
recursive(②, n - 1, t);
recursive(x, y + step, n - 1, t);
recursive(x + step, y, n - 1, t);
recursive(③, n - 1, !t);
}
int main() {
scanf("%d", &n);
recursive(0, 0, ④);
int size = ⑤;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++)
printf("%d", res[i][j]);
puts("");
}
return 0;
}
填空题
-
①处应填()A. n%2B. 0C. tD. 1
-
②处应填()A. x-step,y-stepB. x,y-stepC. x-step,yD. x,y
-
③处应填()A. x-step,y-stepB. x+step,y+stepC. x-step,yD. x,y-step
-
④处应填()A. n-1,n%2B. n,0C. n,n%2D. n-1,0
-
⑤处应填()A. 1<<(n+1)B. 1<<nC. n+1D. 1<<(n-1)
第 20 题
c++
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 10000000;
const int maxs = 10000;
int n;
unsigned a[maxn], b[maxn], res[maxn], ord[maxn];
unsigned cnt[maxs + 1];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%d%d", &a[i], &b[i]);
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i < n; ++i)
①; // 利用cnt数组统计数量
for (int i = 0; i < maxs; ++i)
cnt[i + 1] += cnt[i];
for (int i = 0; i < n; ++i)
②; // 记录初步排序结果
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i < n; ++i)
③; // 利用cnt数组统计数量
for (int i = 0; i < maxs; ++i)
cnt[i + 1] += cnt[i];
for (int i = n - 1; i >= 0; --i)
④; // 记录最终排序结果
for (int i = 0; i < n; i++)
printf("%d %d", ⑤);
return 0;
}
填空题
-
①处应填()A. ++cnt [i]B. ++cnt [b [i]]C. ++cnt [a [i] * maxs + b [i]]D. ++cnt [a [i]]
-
②处应填()A. ord [--cnt [a [i]]] = iB. ord [--cnt [b [i]]] = a [i]C. ord [--cnt [a [i]]] = b [i]D. ord [--cnt [b [i]]] = i
-
③处应填()A. ++cnt [b [i]]B. ++cnt [a [i] * maxs + b [i]]C. ++cnt [a [i]]D. ++cnt [i]
-
④处应填()A. res [--cnt [a [ord [i]]]] = ord [i]B. res [--cnt [b [ord [i]]]] = ord [i]C. res [--cnt [b [i]]] = ord [i]D. res [--cnt [a [i]]] = ord [i]
-
⑤处应填()A. a [i], b [i]B. a [res [i]], b [res [i]]C. a [ord [res [i]]], b [ord [res [i]]]D. a [res [ord [i]]], b [res [ord [i]]]