通过海量题库、编程比赛和实时排名,系统化提升您的编程能力。
第1题
以下哪个是面向对象的高级语言( )。
汇编语言
C++
FORTRAN
Basic
第2题
1TB 代表的字节数量是 ( ).
2 的 10 次方
2 的 20 次方
2 的 30 次方
2 的 40 次方
第3题
二进制数 00100100 和 00010101 的和是 ( ).
00101000
001010100
01000101
00111001
第4题
TCP 协议属于哪一层协议 ( ).
应用层
传输层
网络层
数据链路层
第5题
下列几个 32 位 IP 地址中,书写错误的是 ( ).
162.105.128.27
192.168.0.1
256.256.129.1
10.0.0.1
第6题
在无向图中,所有定点的度数之和是边数的 ( )倍 .
0.5
1
2
4
第7题
对长度位 n 的有序单链表,若检索每个元素的概率相等,则顺序检索到表中任一元素的 平均检索长度为 ( ).
n/2
(n+1)/2
(n-1)/2
n/4
第8题
编译器的主要功能是 ( ).
将一种高级语言翻译成另一种高级语言
将源程序翻译成指令
将低级语言翻译成高级语言
将源程序重新组合
第9题
二进制数 111.101 所对应的十进制数是 ( ).
5.625
5.5
6.125
7.625
第10题
若有变量 int a, float x, y, 且 a=7, x=2.5, y=4.7, 则表达式 x+a%3*(int)(x+y)%2/4 的值大 约是 ( ).
2.500000
2.750000
3.500000
0.000000
第11题
有以下结构体说明和变量定义,如图所示,指针 p、q、r 分别指向一个链表中的三个续 结点。
struct node { int data; node *next; }*p,*q,*r;
现要将 q 和 r 所指的结点先后位置交换,同时要保持链表的连续,以下程序段中错误的是( )。
q->next = r->next; p-> next = r; r->next = q;
p->next = r; q->next = r->next; r->next = q;
q->next = r->next; r->next = q; p->next = r;
r->next = q; q->next = r->next; p->next = r;
第12题
同时查找 2n 个数中的最大值和最小值,最少比较次数为 ( ).
3(n-2)/2
4n-2
2n-2
第13题
设 G 是有 6 个结点的完全图,要得到一颗生成树,需要从 G 中删去( )条边。
6
9
10
15
第14题
以下时间复杂度不是 O(n2 )的排序方法是 ( )
插入排序
归并排序
冒泡排序
选择排序
第15题
以下程序实现了找第二小元素的算法。输入时 n 个不等的数构成的数组 S,输出 S 中第 二小的数 SecondMin 。在最坏的情况下,该算法需要做 ( )次比较。
if (S[1] < S[2]) { FirstMin = S[1]; SecondMin = S[2]; } else { FirstMin = S[2]; SecondMin = S[1]; } for (i = 3; i <= n; i++) if (S[i] < SecondMin) if(S[i] < FirstMin) { SecondMin = FirstMin; FirstMin = S[i]; } else { Second = S[i]; }
2n
n-1
2n-3
第16题
若逻辑变量 A、C 为真, B、D 为假,以下逻辑运算表达式真的有 ( ).
(B ∨C∨D)∨D∧A
((¬ A ∧ B)∨C)∧B
(A ∧B)∨(C∧D∨¬A)
A ∧(D∨ ¬C)∧B
第17题
下列 ( )软件属于操作系统软件。
Microsoft Word
Windows XP
Android
Mac OS X
Oracle
第18题
在 NOI 比赛中,对于程序设计题,选手提交的答案不得包含下列哪些内容( )。
试图访问网络
打开或创建题目规定的输入 /输出文件之外的其他文件
运行其他程序
改变文件系统的访问权限
读写文件系统的管理信息
第19题
以下哪些结构可以用来存储图 ( ).
邻接矩阵
栈
邻接表
二叉树
第20题
下列各无符号十进制整数中,能用八位二进制表示的数有 ( ).
296
133
256
199
第21题
由数字 1,1,2,4,8,8 所组成的不同的四位数的个数是 _____.
第22题
如图所示,图中每条边上的数字表示该边的长度,则从 A 到 E 的最短距离是 _____.
第23题
#include<iostream> using namespace std; int main(){ int a, b, i, tot, c1, c2; cin >> a >> b; tot = 0; for (i = a; i <= b; i++){ c1 = i / 10; c2 = i % 10; if((c1 + c2) % 3 == 0) tot++; } cout << tot << endl; }
输入:
7 31
输出:( )
第24题
#include <iostream> using namespace std; int fun(int n, int minNum, int maxNum) { int tot, i; if(n == 0) return 1; tot = 0; for (i = minNum; i <= maxNum; i++){ tot += fun(n - 1, i + 1, maxNum); } return tot; } int main(){ int n,m; cin >> n >> m; cout << fun(m, 1, n) << endl; return 0; }
6 3
第25题
#include <iostream> #include <string> using namespace std; const int SIZE = 100; int main(){ string dict[SIZE]; int rank[SIZE]; int ind[SIZE]; int i, j, n, tmp; cin >> n; for (i = 1; i <= n; i++){ rank[i] = i; ind[i] = i; cin >> dict[i]; } for(i = 1; i < n; i++){ for(j = 1; j <= n - i; j++){ if(dict[ind[j]] > dict[ind[j + 1]]){ tmp = ind[j]; ind[j] = ind[j + 1]; ind[j + 1] = tmp; } } } for(i = 1; i <= n; i++) rank[ind[i]] = i; for(i = 1; i <= n; i++) cout << rank[i] << " "; cout << endl; return 0; }
7
aaa
aba
bbb
ccc
aa
第26题
#include <iostream> using namespace std; const int SIZE = 100; int alive[SIZE]; int n; int next(int num){ do { num++; if (num > n) num = 1; } while(alive[num] == 0); return num; } int main() { int m, i, j, num; cin >> n >> m; for (i = 1; i <= n; i++) alive[i] = 1; num = 1; for (i = 1; i <= n; i++){ for(j = 1; j < m; j++) num = next(num); cout << num << " "; alive[num] = 0; if (i < n) num = next(num); } cout << endl; return 0; }
11 3
第27题
(双栈模拟数组) 只使用两个栈结构 stack1 和 stack2,模拟对数组的随机读取。作为栈 结构, stack1 和 stack2 只能访问栈顶 (最后一个有效元素) 。栈顶指针 top1 和 top2 均指向栈 顶元素的下一个位置。 输入第一行包含的两个整数,分别是数组长度 n 和访问次数 m,中间用单个空格隔开。 第二行包含 n 个整数,一次歌出数组各项(数组下标从 0 到 a-1)。第三行包含 m 个整数, 需要访问的数组下标。对于每次访问,输出对应的数组元素。
#include <iostream> using namespace std; const int SIZE = 100; int stack1[SIZE], stack2[SIZE]; int top1, top2; int n, m, i, j; void clearStack(){ int i; for(i = top1; i < SIZE; i++) stack1[i] = 0; for(i = top2; i < SIZE; i++) stack2[i] = 0; } int main(){ cin >> n >>m; for(i = 0; i < n; i++) cin >> stack1[i]; top1 = ①; top2 = ②; for(j = 0; j < m; j++){ cin >> i; while (i < top1 - 1){ top1--; ③; top2++; } while(i > top1 - 1){ top2--; ④; top1++; } clearStack(); cout << stack1[⑤] << endl; } return 0; }
第28题
(最大矩阵和 )给出 M 行 N 列的整数矩阵,就最大的子矩阵和(子矩阵不能为空) 。 输入第一行包含两个整数 M 和 N, 即矩阵的行数和列数。之后 M 行,每行 N 个整数,描述 整个矩阵。程序最终输出最大的子矩阵和。
#include <iostream> using namespace std; const int SIZE = 100; int matrix[SIZE + 1][SIZE + 1]; int rowsum[SIZE + 1][SIZE + 1]; int m, n, i, j, first, last, area, ans; int main(){ cin >> m >>n; for(i = 1; i <= m; i++) for(j = 1; j <= n; j++) cin >> matrix[i][j]; ans = matrix ①; for(i = 1; i <= m; i++) ②; for(i = 1; i <= m; i++) for(j = 1; j <= n; j++) rowsum[i][j] = ③; for(first = 1; first <= n; first++) for(last = first; last <= n; last++){ ④; for(i = 1;l i <= m; i++){ area += ⑤ ; if(area > ans) ans = area; if(area < 0) area = 0; } } cout << ans << endl; return 0; }
一、单项选择题(1-15 共 10 题 ); 二、不定项选择题(16-20 共 5 题); 三、问题求解(21-22 共 2 题); 四、阅读程序写结果(23-26 共 4 题); 五、完善程序(27-28 共2题)。