#YHCSPJ0009. CSP-J模拟卷9
CSP-J模拟卷9
选择题
- (2分)已知十进制中的18在x的进制中的表示为24,即(18)₁₀=(24)ₓ,则这个x进制为()进制。{{ select(1) }}
- 9
- 8
- 7
- 6
- (2分)根据网址的域名http://www.jiangsu.gov.cn/,可以判断出该网站是()类型的网站。{{ select(2) }}
- 商业机构
- 军事机构
- 政府机构
- 组织机构
- (2分)与计算机硬件关系最密切的软件是()。{{ select(3) }}
- 编译程序
- 操作系统
- 游戏程序
- 数据库管理程序
- (2分)下列程序段执行后s的值为()。{{ select(4) }}
int i=1, s=0;
while(i++)
if(!(i%3)) break;
else s+=i;
- 6
- 3
- 2
- 以上均不是
- (2分)将19分解成3个不重复数字(1~9)之和(不计顺序)的方法有()种。{{ select(5) }}
- 6
- 5
- 4
- 3
- (2分)甲、乙、丙三位同学选修课程,在四门课程中,甲选修两门,乙、丙各选修三门,则不同选修方案共有()种。{{ select(6) }}
- 36
- 48
- 64
- 96
- (2分)已知某二叉树的先序遍历序列是ABDCE,中序遍历序列是BDAEC,则该二叉树的后序遍历为()。{{ select(7) }}
- BDECA
- DBECA
- DBCEA
- BDCEA
- (2分)计算机启动时,可以通过存储在()中的引导程序引导操作系统。{{ select(8) }}
- ROM
- RAM
- Cache
- CPU
- (2分)表达式a+b*c-(d+e)的前缀形式是()。{{ select(9) }}
- abc*+de+-
- -+*abc+de
- -+a*bc+de
- abcde*++-
- (2分)小军在家玩关灯游戏,灯有白、黄、红三种颜色。按1下白灯亮,按2下灯灭,按3下黄灯亮,按4下灯灭,按5下红灯亮,按6下灯灭,循环。按49次和100次时灯的状态是()。{{ select(10) }}
- 灯灭,灯灭
- 红灯亮,灯灭
- 白灯亮,红灯亮
- 白灯亮,灯灭
- (2分)704与2048的最小公倍数是()。{{ select(11) }}
- 45056
- 22528
- 180224
- 90112
- (2分)在()的情况下,函数A∨B运算的结果是逻辑“0”。{{ select(12) }}
- A和B全部是1
- A和B任一是1
- A和B全部是0
- A和B任一为0
- (2分)小明夫妇请小刚夫妇和小伟夫妇玩扑克,规则:夫妇不能一组。小明和小红一组,小刚的队友是小伟的妻子,琳达的丈夫和小丽一组。三对夫妇是()。{{ select(13) }}
- 小明-小丽,小刚-琳达,小伟-小红
- 小明-琳达,小刚-小红,小伟-小丽
- 小明-小丽,小刚-小红,小伟-琳达
- 小明-小红,小刚-小丽,小伟-琳达
- (2分)4人过桥,时间1、2、5、10分,需灯,一次2人,时间以多的为准,最少时间()分。{{ select(14) }}
- 15
- 16
- 17
- 18
- (2分)2000年,华人学者姚期智因计算理论成就获()。{{ select(15) }}
- 图灵奖
- 奥斯卡奖
- 诺贝尔奖
- 普利策奖
阅读理解1(12分)
#include<iostream>
using namespace std;
int main() {
const int SIZE=10;
int height[SIZE], num[SIZE], n, ans;
cin >> n;
for (int i=0; i<n; i++) {
cin >> height[i];
num[i] = 1;
for (int j=0; j<i; j++) {
if ((height[j] < height[i]) && (num[j] >= num[i]))
num[i] = num[j] + 1;
}
}
ans = 0;
for (int i=0; i<n; i++) {
if (num[i] > ans) ans = num[i];
}
cout << ans << endl;
return 0;
}
第16题(1.5分)
如果height数组输入有负数,程序会出错。(){{ select(16) }}
- 正确
- 错误
第17题(1.5分)
程序输出的ans小于或等于n。(){{ select(17) }}
- 正确
- 错误
第18题(1.5分)
将12行“num[j]>=num[i]”改为“num[j]>num[i]”,输出结果不变。(){{ select(18) }}
- 正确
- 错误
第19题(1.5分)
将18行“num[i]>ans”改为“num[i]>=ans”,输出结果不变。(){{ select(19) }}
- 正确
- 错误
第20题(3分)
输入10个1,输出:{{ select(20) }}
- 4
- 3
- 2
- 1
第21题(3分)
输入3 2 5 11 12 7 4 10 15 6,输出:{{ select(21) }}
- 4
- 5
- 6
- 7
阅读理解2(14分)
#include<iostream>
using namespace std;
int n, m, i, j, p, k;
int a[100], b[100];
int main() {
cin >> n >> m;
a[0] = n; i=0; p=0; k=1;
do {
for (j=0; j<i; j++)
if (a[i] == a[j]) {
p=1; k=j; break;
}
if (p) break;
b[i] = a[i]/m;
a[i+1] = a[i]%m*10;
i++;
} while (a[i] != 0);
cout << b[0] << ".";
for (j=1; j<k; j++) cout << b[i];
if (p) cout << "(";
for (j=k; j<i; j++) cout << b[j];
if (p) cout << ") ";
cout << endl;
return 0;
}
第22题(2分)
程序输入的n和m不能相等。(){{ select(22) }}
- 正确
- 错误
第23题(2分)
程序输入的m不能等于0。(){{ select(23) }}
- 正确
- 错误
第24题(2分)
第9~19行的do…while循环有2个出口。(){{ select(24) }}
- 正确
- 错误
第25题(2分)
数组a和b中的数值都小于或等于n。(){{ select(25) }}
- 正确
- 错误
第26题(3分)
输入“11 8”,输出:{{ select(26) }}
- 0.375
- 0.(375)
- 1.375
- 1.(375)
第27题(3分)
输入“5 13”,输出:{{ select(27) }}
- 0.386514
- 0.(386514)
- 0.384615
- 0(384615)
阅读理解3(14分)
#include<iostream>
using namespace std;
const int V=100;
int n, m, ans, e[V][V];
bool visited[V];
void dfs(int x, int len) {
int i;
visited[x] = true;
if (len > ans) ans = len;
for (i=1; i<=n; i++)
if ((!visited[i]) && (e[x][i] != -1))
dfs(i, len+e[x][i]);
visited[x] = false;
}
int main() {
int i, j, a, b, c;
cin >> n >> m;
for (i=1; i<=n; i++)
for (j=1; j<=n; j++)
e[i][j] = -1;
for (i=1; i<=m; i++) {
cin >> a >> b >> c;
e[a][b] = c;
e[b][a] = c;
}
for (i=1; i<=n; i++)
visited[i] = false;
ans = 0;
for (i=1; i<=n; i++)
dfs(i, 0);
cout << ans << endl;
return 0;
}
第28题(1.5分)
第19行输入若m=n*(n-1)/2,20~22行初始化可省略。(){{ select(28) }}
- 正确
- 错误
第29题(1.5分)
第31行换成“for(i=n;i>=1;i--)”,结果不受影响。(){{ select(29) }}
- 正确
- 错误
第30题(3分)
输入4 2,1 2 1,3 4 1,输出:{{ select(30) }}
- 8
- 4
- 2
- 1
第31题(3分)
输入4 6,各边权1,输出:{{ select(31) }}
- 1
- 3
- 5
- 7
第32题(3分)
输入4 3,边为1-2(10)、2-3(20)、3-1(30),输出:{{ select(32) }}
- 30
- 60
- 90
- 120
第33题(3分)
输入4 6,边权10、20、30、40、50、60,输出:{{ select(33) }}
- 60
- 100
- 150
- 200
编程填空1(15分)
题目描述:高精度加法
struct HugeInt {
int len;
int num[100001];
};
HugeInt a, b, w;
char c[100001], d[100001];
void Scan_HugeInt() {
cin >> c >> d;
len = strlen(c);
len = strlen(d);
for (int i=0; i< len; i++)
①;
for (int i=0; i< len; i++)
②;
}
void Plus() {
w.len = max( len, len);
for (int i=1; i<=w.len; i++) {
w.num[i] += ③;
w.num[i+1] += ④;
w.num[i] %= 10;
}
if (⑤)
w.len ++;
}
第34题(3分)①处应填(){{ select(34) }}
- num[i]=c[i]-‘0’
- num[ len-i]=c[i]-‘0’
- num[ len]=c[i]
- num[i]=c[i]
第35题(3分)②处应填(){{ select(35) }}
- num[i]=d[i]
- num[ len-i]=d[i]
- num[ len-i]=d[i]-‘0’
- num[i]=d[i]-‘0’
第36题(3分)③处应填(){{ select(36) }}
- ( num[i]+ num[i])
- ( num[i]+ num[i])%10
- ( num[i]%10+ num[i]%10)
- ( num[i]+ num[i]-10)
第37题(3分)④处应填(){{ select(37) }}
- w.num[i]/10
- w.num[i]
- w.num[i]%10
- w.num[i]-10
第38题(3分)⑤处应填(){{ select(38) }}
- w.num[w.len+1]>=0
- w.num[w.len+1]==0
- w.num[w.len+1]!=0
- w.num[w.len+1]>1
编程填空2(15分)
题目描述:马走日回溯
int r, c;
int cnt, tot;
int wayr[8] = {2, 2, 1, -1, -2, -2, 1, -1};
int wayc[8] = {1, -1, 2, 2, 1, -1, -2, -2};
bool mark[1001][1001];
bool check(int x, int y) {
if (①) return true;
return false;
}
void search(int x, int y) {
for (int i=0; i<8; i++)
if (② && ③) {
mark[x+wayr[i]][y+wayc[i]] = true;
tot++;
if (④) cnt++;
search(⑤);
tot--;
mark[x+wayr[i]][y+wayc[i]] = false;
}
}
第39题(3分)①处应填(){{ select(39) }}
- x>=0 || y>=0 || x<r || y<c
- x>=0 || y>=0 && x<r || y<c
- x>=0 && y>=0 && x<r && y<c
- x>=0&&y>=0|| x<r &&y<c
第40题(3分)②处应填(){{ select(40) }}
- check(wayr[i], wayc[i])
- check(x+wayr[i], y+wayc[i])
- !check(x+wayr[i], y+wayc[i])
- !check(wayr[i], wayc[i])
第41题(3分)③处应填(){{ select(41) }}
- mark[wayr[i]][wayc[i]]
- mark[x+wayr[i]][y+wayc[i]]
- !mark[wayr[i]][wayc[i]]
- !mark[x+wayr[i]][y+wayc[i]]
第42题(3分)④处应填(){{ select(42) }}
- tot==r * c-1
- tot==r * c
- cnt==r * c-1
- cnt==r * c
第43题(3分)⑤处应填(){{ select(43) }}
- wayr[i], wayc[i]
- x-wayr[i], y-wayc[i]
- x-wayr[i], y+wayc[i]
- x+wayr[i], y+wayc[i]