云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 浙江省高等学校二级C语言(笔试部分真题2008-2010年)

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

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 10:56:20

试题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

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

试题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;

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com