2014年信息学奥赛NOIP普及组
剩余时间 --:--:--
单选题 共 20 题
1.

断电后会丢失数据的存储器是( )。

2.

设有100个数据元素,采用折半搜索时, 最大比较次数为( )。

3.

二进制数 00100100 和 00010101 的和是( )。

4.

CPU、存储器、I/O设备是通过( )连接起来的。

5.

若有如下程序段,其中s、a、b、c均已定义为整型变量, 且a、c均已赋值,c>0。s=a;

for (b = 1; b <= c; b++)

s += 1;

则与上述程序段功能等价的赋值语句是( )。

6.

下列对操作系统功能的描述最为完整的是( )。


7.

设变量x为float型且已赋值,则以下语句中能将x中的数值保留到小数点后两位, 并 将第三位四舍五入的是( )。

8.

链表不具有的特点是( )。

9.

下列几个32位IP地址中,书写错误的是( )。

10.

要求以下程序的功能是计算:s = 1 + 1/2 + 1/3 + ... + 1/10。

#include <iostream>

using namespace std;

int main() {

int n;

float s;

s = 1.0;

for (n = 10; n > 1; n--)

s = s + 1 / n;

cout << s << endl;

return 0;

}

程序运行后输出结果错误,导致错误结果的程序行是( )。

11.

1TB 代表的字节数量是( )。

12.

有向图中每个顶点的度等于该顶点的( )。

13.

以下哪个是面向对象的高级语言( )。

14.

一棵具有 5 层的满二叉树中结点数为( )。

15.

下列选项中不属于图像格式的是( )。

16.

以下哪一种设备属于输出设备( )。

17.

有以下程序:

#include <iostream>

using namespace std;

int main() {

int s, a, n;

s = 0;

a = 1;

cin >> n;

do {

s += 1;

a -= 2;

} while (a != n);

cout << s << endl;

return 0;

}

若要使程序的输出值为2,则应该从键盘给n输入的值是( )。

18.

以下哪一种是属于电子邮件收发的协议( )。

19.

计算机界的最高奖是( )。

20.

列各无符号十进制整数中,能用八位二进制表示的数中最大的是( )。

填空题 共 1 题
1.

如图所示,图中每条边上的数字表示该边的长度,则从A到E的最短距离是         

编程题 共 7 题
1.
#include <iostream>
using namespace std;

int main() {
	int a, b, c, d, ans;
	cin >> a >> b >> c;
	d = a - b;
	a = d + c;
	ans = a * b;
	cout << "Ans = " << ans << endl;
	return 0;
}

输入: 2 3 4

输出:           

2.
#include <iostream>
using namespace std;

int fun(int n) {
	if (n == 1)
		return 1;
	if (n == 2)
		return 2;
	return fun(n - 2) - fun(n - 1);
}

int main() {
	int n;
	cin >> n;
	cout << fun(n) << endl;
	return 0;
}

输入: 7

输出:           

3.
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string st;
	int i, len;
	getline(cin, st);
	len = st.size();
	for (i = 0; i < len; i++){
		if (st[i] >= 'a' && st[i] <= 'z')
			st[i] = st[i] - 'a' + 'A';
	}
	cout << st << endl;
	return 0;
}

输入: Hello, my name is Lostmonkey.

输出:                                                     

4.

把M个同样的球放到N个同样的袋子里,允许有的袋子空着不放,问共有多少种不同的放置方法?(用K表示)。

例如:M=7,N=3时,K=8;在这里认为(5,1,1)和(1,5,1)是同一种放置方法。

问:M=8,N=5时,K=       

5.
#include <iostream>
using namespace std;

const int SIZE = 100;

int main()
{
	int p[SIZE];
	int n, tot, i, cn;
	tot = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
		p[i] = 1;
	for (i = 2; i <= n; i++){
		if (p[i] == 1)
			tot++;
		cn = i * 2;
		while (cn <= n) {
			p[cn] = 0;
			cn += i;
		}
	}
	cout << tot << endl;
	return 0;
}

输入: 30

输出:              

6.

完善程序:(最大子矩阵和)给出m行n列的整数矩阵,求最大的子矩阵和(子矩阵不能为空)。

输入第一行包含两个整数m和n,即矩阵的行数和列数。之后m行,每行n个整 数,描述整个矩阵。程序最终输出最大的子矩阵和。 (最后一空 4 分, 其余 3 分, 共 16 分)


#include <iostream>

using namespace std;


const int SIZE = 100;

int matrix[SIZE + 1][SIZE + 1];

int rowsum[SIZE + 1][SIZE + 1];   //rowsum[i][j]记录第 i 行前 j 个数的和 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     (1)     ;

for (i = 1; i <= m; i++)

        (2)    ;

for (i = 1; i <= m; i++)

for (j = 1; j <= n; j++)

rowsum[i][j] =     (3)     ;

for (first = 1; first <= n; first++)

for (last = first; last <= n; last++) {

                       (4)    ;

for (i = 1; i <= m; i++) {

area +=     (5)    ;

if (area > ans)

ans = area;

if (area < 0)

area = 0;

}

}

cout << ans << endl;

return 0;

}

7.

完善程序:(数字删除)下面程序的功能是将字符串中的数字字符删除后输出。请填空。(每空3分, 共12分)


#include <iostream>

using namespace std;


int delnum(char *s) {

int i, j;

j = 0;

for (i = 0; s[i] != '\0'; i++)

if (s[i] < '0'    (1)     s[i] > '9') {

s[j] = s[i];

                      (2)    ;

}

return     (3)    ;

}


const int SIZE = 30;


int main() {

char s[SIZE];

int len, i;

cin.getline(s, sizeof(s));

len = delnum(s);

for (i = 0; i < len; i++)

cout <<     (4)    ;

cout << endl;

return 0;

}

C++ 编辑器
输入
输出