第一范文网 - 专业文章范例文档资料分享平台

浙江省高等学校二级C语言(笔试部分真题2008-2010年)

来源:用户分享 时间:2025/5/15 18:59:53 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

试题7 (28分)

#include #include double fact(int n); double cal(double e); void main() {

int i,n; double e=1;

printf(\

while(scanf(\ for(i=1;i<=n;i++) {

e=e*1.0/10;

printf(\ } }

double fact(int n) {

double y=1; int i;

for(i=1;i<=n;i++) y=y*i; return y; }

double cal(double e) {

double s=0,t=1; int i=1; while(t>=e) { s=s+t;

t=1/fact(++i); }

return s; }

29

2008年春浙江省高等学校

计算机等级考试试卷(二级C)

说明:(1) 考生应将所有试题的答案填写在答卷上。其中试题1到试题6请在答卷上各小题正

确选项的对应位置处填“√”;

(2) 请将你的准考证号的后五位填写在答卷右下角的指定位置内; (3) 考试时间为90分钟。 试题1(每小题3分,共12分)

阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序说明】

输入1个正整数n(n>=2),输出菲波那契(Fibonacci)序列的前n项,每行输出6个数。菲波那契(Fibonacci)序列:1,1,2,3,5,8,13,??,数列的前两个数都是1,从第三个数开始,每个数是前两个数之和。

运行示例: Enter n:10

1 1 2 3 5 8 13 21 34 55 【程序】

#include main( ) {

int count, i, n, x1, x2, x; printf(”Enter n:”); scanf(”%d”,&n); x1 = x2 = 1;

printf(”mm”,x1, x2); (1) ;

for(i = 1; i <= n-2; i++){ (2) ;

printf(”m”, x); count++;

if( (3) ) printf(”\\n”); x1 = x2;

(4) ; } }

【供选择的答案】

(1) A、count = 2 B、count = 0

C、count = 1 D、count = -1

(2) A、x = x1 – x2 B、x = x1 + x2

C、x = x1 D、x = 2

(3) A、count / 6 == 0 B、count % 6 != 0

C、count % 6 == 0 D、count / 6 != 0

(4) A、x = x1 +x2 B、x2 = x1

C、x = x2 D、x2 = x

试题2(每小题3分,共12分)

30

阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序说明】

输入2个正整数m和n(1<=m

Enter m, n: 1 10 count = 4, sum = 17 【程序】

#include #include int prime(int m) { int i, n;

if(m == 1) return (5) ; n = sqrt(m);

for(i = 2; i <= n; i++)

if(m % i == 0) return (6) ; return (7) ;

}

main()

{ int count = 0, i, m, n, sum = 0; printf(”Enter m, n:”); scanf(”%d%d”,&m, &n); for(i = m; i <= n; i++) if( (8) ){ sum += i; count++; }

printf(\}

【供选择的答案】

(5) A、1 B、m

C、m == 1 D、0 (6) A、m B、1 C、0 D、n (7) A、m B、1

C、0 D、i == n (8) A、prime(i) != 0 B、prime(i) == 0 C、i == prime(i) D、!prime(i) 试题3(每小题3分,共12分)

阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序说明】

输入一个2 * 3的二维数组,找到最大值以及它的行下标和列下标,并输出该矩阵。 运行示例:

Enter a array(2*3):3 2 10 -9 6 -1 max = a[0][2] = 10 3 2 10 -9 6 -1

【程序】

31

#include main( ) { int col, i, j, row; int a[2][3];

printf(\ for(i = 0; i <2; i++)

for(j = 0; j < 3; j++)

scanf(\

(10) ;

for(i = 0; i < 2; i++) for(j = 0; j < 3; j++)

if(a[i][j] > a[row][col]){ (11) ; }

printf(”max = a[%d][%d] = %d\\n”, row, col, a[row][col]); for(i = 0; i < 2; i++){ for(j = 0; j < 3; j++)

printf(”M”, a[i][j]);

(12)

}

【供选择的答案】

(9) A、&a[i][j] B、&a[j][i] C、a[i][j] D、a[j][i]

(10) A、row = col = 2; B、row = col = 0; C、a[row][col] = 0; D、a[row][col] = -1; (11) A、row = j; col = i; B、a[row][col] = a[i][j]; C、row = i; col = j; D、a[row][col] = a[j][i]; (12) A、printf(”\\n”)}; B、}printf(”\\n”); C、; D、printf(”\\n”);}

试题4(每小题3分,共12分)

阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。

【程序】

#include main()

{ int op1, op2, res; char operator;

scanf(”%d”, &op1); operator = getchar(); while(operator != ?=?){ scanf(”%d”, &op2); switch(operator){

case ?+?: res = op1+op2; break; case ?-?: res = op1-op2; break; case ?*?: res = op1*op2; break; case ?/?: res = op1/op2; break; default: res = 0; }

op1 = res;

operator = getchar();

32

浙江省高等学校二级C语言(笔试部分真题2008-2010年).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1bu5h3ccg28ojis8frd8_8.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top