#jaco1. jaco-J1
jaco-J1
2025~2026 CFF 非专业级别软件能力认证 -第一期- 第一轮(CSQ-J1)入门级 C++语言试题
一、单项选择题(共15题,每题2分,共计30分;每题有且仅有一个正确选项)
- 关于计算机,下列说法错误的是()。{{ select(1) }}
- CPU、GPU 都是计算机的硬件部分。
- 计算机主要分为硬件和软件两部分。
- 计算机关机后 RAM 中的数据不会丢失,而 ROM 中的数据会丢失。
- 世界上第一台计算机诞生于 1946 年。
- 在 C++ 中,()类型可表达的最大数最大。{{ select(2) }}
intlong longdoublechar
- 关于计算机语言,下列说法正确的是()。{{ select(3) }}
- 计算机的基本语言是机器语言。
- 计算机的基本语言是汇编语言。
- C++ 是面向过程的语言。
- Java 和 C++ 的语言类型不同。
-
在双向链表的非尾元素 后添加元素 ,能实现正确结果的( )。
① r->next=p->next,r->pre=p ② r->next=p->next,r->pre=p,p->next->pre=r,p->next=r ③ r->next=p->next,r->pre=p,p->next=r,p->next->pre=r ④ r->next=p->next,p->next=r,r->pre=p,p->next->next->pre=r{{ select(4) }}
- ①②
- ①③
- ②④
- ③④
- 下列数据结构中,()不能直接获取第一个加入容器的值(假设现在容器内已经加入其他新元素)。{{ select(5) }}
- 栈
- 链表
- 队列
- 向量
- 计算 的结果为()。{{ select(6) }}
- 一棵根节点深度为 0,节点数为 12345 的 4 叉树高度至少为()。{{ select(7) }}
- 5
- 6
- 7
- 8
-
定义结构体:
struct Node { int data; Node *next; };若要将结构体
a的成员next指向的结构体的成员next指向结构体c,下列实现正确的是()。{{ select(8) }}
a.next.next = ca.next->next = ca.next->next = &ca->next->next = &c
- 小明一天要完成九科作业(语、数、英、物、化、生、史、地、政),其中数、物、化、生四科的作业要一起完成,政治作业最后完成,那么他有()种安排方式。{{ select(9) }}
- 1440
- 2880
- 720
- 5760
- 有一组字符 $\{\mathrm{C},\mathrm{A},\mathrm{J},\mathrm{S},\mathrm{O},\mathrm{Q}\}$,对应频率分别为 ,以下()不能作为它们的哈夫曼编码。{{ select(10) }}
00000,00001,0001,001,01,101011,01010,0100,011,00,110111,10110,1010,100,11,010011,10010,1100,100,11,0
- 计算机的基本存储单位是()。{{ select(11) }}
- bit
- Byte
- Boolean
- 高低电压
- 以下()不是操作系统。{{ select(12) }}
- Unix
- Lunix
- Windows
- Mac OS
- 对有向图 (A->B),(A->C),(B->D),(C->D) 和 (A->B,B->C,C->D,D->A) 分别进行拓扑排序,正确的是()。{{ select(13) }}
- A->B->C->D,A->B->C->D
- A->B->D->C,无法进行拓扑排序
- A->C->B->D,A->B->C->D
- A->C->B->D,无法进行拓扑排序
- 逆波兰表达式
2 3 + 5 * 3 4 2 / + 3 * -的结果为()。{{ select(14) }}
- 10
- 2
- 14
- 20
- 一棵二叉树的前序遍历为
CcaJoQS,则其中序遍历不可能为()。{{ select(15) }}
JcaoCQSJacoSCQJacoCSQCoJQaSc
二、阅读程序(程序输入不超过数组或字符串定义的范围;判断题正确填对,错误填错;除特殊说明外,判断题1.5分,选择题3分,共计40分)
(1)
#include<iostream>
using namespace std;
int main() {
int a, b, ansa = 0, ansb = 0;
cin >> a >> b;
for(int i = a; i <= b && i > 0; i++) {
int x = i, cnta = 0, cntb = 0;
while(x != (x&-x)) x &= -x, cnta++;
while(x && !(x&1)) cntb++, x >>= 1;
ansa += cnta, ansb += cntb;
}
cout << ansa << ' ' << ansb << endl;
return 0;
}
输入 为小于 的正整数,且 。
- 删去第 8 行的
x=i,,并把后续对x的操作改为对i的操作,程序输出无影响。(){{ select(16) }}
- 对
- 错
- 输入
2 8,程序输出4 8。(){{ select(17) }}
- 对
- 错
cntb用于计算当前数x中因子 2 的数量。(){{ select(18) }}
- 对
- 错
- (2分)输出
ansa一定小于等于ansb。(){{ select(19) }}
- 对
- 错
- 设 ,该程序时间复杂度为()。{{ select(20) }}
- (3.5分)输入
2 2147483647,如果运行足够的时间并正常运行,程序将输出()。{{ select(21) }}
2147483616 21474836162147483616 21474836172147483617 21474836162147483617 2147483617
(2)
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 1e3 + 5;
int n, a[MAXN][MAXN], b[MAXN][MAXN], f[MAXN][MAXN];
int main() {
cin >> n;
for(int i = 1; i <= n; i++) {
for(int j = 1; j<= i; j++) {
scanf("%d", a[i] + j);
int &p = *(a[i]+j);
b[i][j] = * &p;
a[i][j] += (a[i-1][j] > a[i-1][j-1] ? a[i-1][j] : a[i-1][j-1]);
}
}
memset(f+1, 63, MAXN * n * 4);
for(int i = n - 1; i + 1; i--) {
for(int j = 0; j <= i; j++) {
f[i+1][j+1] = b[i+1][j+1] + (f[i+2][j+1] < f[i+2][j+2] ? f[i+2][j+1] : f[i+2][j+2]);
}
}
cout << *max_element(a[n] + 1, a[n] + 1 + n) << endl;
cout << *min_element(f[1] + 1, f[1] + n + 1) << endl;
return 0;
}
输入 为不超过 2000 的正整数,且 。
- 该程序运行中可能有变量的值溢出。(){{ select(22) }}
- 对
- 错
- 在程序正常运行的情况下,把第 24 行改为
cout << f[1][1] << endl;,程序输出不受任何影响。(){{ select(23) }}
- 对
- 错
- 该程序可能会运行时错误,其根本原因是
memset操作范围可能超出数组f的范围。(){{ select(24) }}
- 对
- 错
- 该程序存在编译问题,以下()为合理的解决方法。{{ select(25) }}
- 在程序头部添加头文件
<memory.h>。 - 在程序头部添加头文件
<cstring>。 - 在程序头部添加头文件
<cstdlib>。 - 删掉第 17 行的内容。
- 输入:
5
3
2 5
4 1 7
2 3 1 3
6 6 8 1 5
程序输出()。{{ select(26) }}
8 2326 824 832 7
- 若输入
n为 100,且 ,程序输出()。{{ select(27) }}
5050 100100 25252525 1005049 101
(3)
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, m, q, dist = 0, *ans;
vector<vector<int>> a;
void V() {return; }
int calc(int x, int y, int z, int t) {
int s1 = x-z > 0 ? x-z : z-x;
int s2 = y-t < 0 ? t-y : y-t;
return s1 * s2 + s1 + s2 + 1;
}
void func(int m, int n, int p, int q, vector<vector<int> > &d) {
int v = d[p+1][q+1];
d[p+1][q+1] = 0;
d[m][n] += ++d[p+1][q+1];
d[m][q+1] -= d[p+1][q+1], d[p+1][n] -= --(++d[p+1][q+1]);
d[p+1][q+1] += v;
return dist += calc(m, n, p, q), V();
}
void solve(int x, vector<vector<int> > &d) {
for(int i = 1; i <= x; i++) {
int r, s, t, u;
cin >> r >> s >> t >> u;
func(r, s, t, u, d);
}
a = d;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
a[i][j] += a[i-1][j] + a[i][j-1] - a[i-1][j-1];
}
}
vector<vector<int> > ::iterator t = max_element(a.begin(), a.end());
vector<int> ::iterator maxt = max_element(t->begin(), t->end());
ans = &*maxt;
return V();
}
int main() {
cin >> n >> m >> q;
a = vector<vector<int> > (n+1, vector<int> (m+1, 0));
auto d = a;
solve(q, d);
cout << dist << ' ' << *ans << endl;
return 0;
}
输入 为不超过 1200 的正整数,且 。
- (2分)程序 38、39 两行用于求二维向量
a中的最大值。(){{ select(28) }}
- 对
- 错
- 程序时间复杂度主要为 。(){{ select(29) }}
- 对
- 错
- 输入:
3 5 4
1 1 3 5
1 1 1 2
2 3 3 5
3 5 3 5
程序输出()。{{ select(30) }}
15 324 215 254 3
- 该程序存在哪些问题?{{ select(31) }}
- 第 40 行
ans = &*maxt写法存在问题。 - 第 38、39 行的地址和指针运算存在问题。
- 输出答案应改为
cout << dist << endl << ans << endl;。 - 向量定义过小。
- (4分)若把第 32 行改为
memcpy(d, a, sizeof d);,程序()。{{ select(32) }}
- 可以正常运行,但不一定输出正确结果。
- 一定会异常结束。
- 一切正常。
- 有时不能正常运行,但是正常运行时一定能输出正确结果。
三、完善程序(单选题,每小题3分,共计30分)
(1)(计算波兰表达式的值)
其中,每一个数均为正整数且不超过 10。
试补全程序。
#include<iostream>
#include<stack>
using namespace std;
int main() {
string s;
cin >> s;
stack<int> num;
for(int i = s.size() - 1; __①__; i--) {
if(s[i] >= __②__ && s[i] <= 57) {
num.push(s[i] - __②__);
}
else {
int a = __③__;
int b = __③__;
switch(s[i]){
case '+': num.push(a + b); break;
case '-': num.push(a - b); break;
case '*': num.push(a * b); break;
case '/': num.push(__④__); break;
}
}
}
cout << __⑤__;
}
- ①处应填()。{{ select(33) }}
ii + 1i - 1i++
- ②处应填()。{{ select(34) }}
'9'47480
- ③处应填()。{{ select(35) }}
num.top()num.pop()num.front(); num.pop()num.top(); num.pop()
- ④处应填()。{{ select(36) }}
a / bb / a1 / b * a1 / a * b
- ⑤处应填()。{{ select(37) }}
num[0]&(num->top)num.pop()(&num)->top()
(2)(树的遍历)
输入一棵树,分别进行前序、中序、后序和层次遍历。
其中 "u v rota" 代表节点 v 为节点 u 的子节点;当 rota = 0 时,v 为 u 的左子节点;rota = 1 时,v 为 u 的右子节点。保证输入为一棵合法的树。
试补全程序。
#include<iostream>
#include<string.h>
#include<queue>
using namespace std;
struct Node {
int data;
Node *left = nullptr;
Node *right = nullptr;
} tree[1<<20];
void PreT(Node *root) {
cout << __①Ⅰ__ << ' ';
if(root -> left != nullptr) PreT(__①Ⅱ__);
if(root -> right != nullptr) PreT(__①Ⅲ__);
}
void InT(Node *root) {
if(root -> left != nullptr) InT(__①Ⅱ__);
cout << __①Ⅰ__ << ' ';
if(root -> right != nullptr) InT(__①Ⅲ__);
}
void PostT(Node *root) {
if(root -> left != nullptr) PostT(__①Ⅱ__);
if(root -> right != nullptr) PostT(__①Ⅲ__);
cout << __①Ⅰ__ << ' ';
}
void LevelT(__②__root) {
queue<__②__> q;
q.push(root);
while(!q.empty()) {
__③__; q.pop();
cout << u -> data << ' ';
if(u -> left != nullptr) q.push(u -> left);
if(u -> right != nullptr) q.push(u -> right);
}
}
int main() {
int n;
cin >> n;
for(int i = 1; i <= n; i++) {
tree[i].data = i;
}
for(__④__) {
int data, u, v, rota;
cin >> u >> v >> rota;
if(rota == 0) tree[u].left = &tree[v];
else tree[u].right = &tree[v];
}
bool leaf[1<<20];
memset(leaf, 0, sizeof leaf);
Node *root;
for(int i = 1; i <= n; i++) {
if(tree[i].left != nullptr) leaf[tree[i].left - tree] = 1;
if(tree[i].right != nullptr) leaf[tree[i].right - tree] = 1;
}
for(int i = 1; i <= n; i++) {
if(leaf[i] == 0) root = ⑤;
}
PreT(root); cout << endl;
InT(root); cout << endl;
PostT(root); cout << endl;
LevelT(root); cout << endl;
return 0;
}
- ①处应分别填()。{{ select(38) }}
root.data、root.left、root.rightdata、left、rightroot -> data、root -> left、root -> rightroot、left、right
- ②处应填()。{{ select(39) }}
NodeNode *intstruct Node
- ③处应填()。{{ select(40) }}
Node u = q.front()Node *u = q.top()Node *u = q.front()q.front() = u
- ④处应填()。{{ select(41) }}
int i = 1; i <= n; i++int i = 0; i < n; i++int i = 1; i < n; i++int i = n; i; i--
- ⑤处应填()。{{ select(42) }}
tree -> itree[i]tree + i*tree + i
相关
在下列比赛中: