计算机二级c语言

发布时间 : 星期三 文章计算机二级c语言更新完毕开始阅读

C. 5 5 D. 5 15

(15) 程序3运行时,输出 (15) 。

A. 0 15 B. 5 0 C. 5 5 D. 5 15

(16) 程序4运行时,输出 (16) 。

A. 0 15 B. 5 0 C. 5 5 D. 5 15

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

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

#include void main() { int i, m=15, y=-1;

for(i=2; i<=m/2; i++) if(m % i= =0) y=0; else y=1;

printf(“%d”,y); }

程序2

#include void main() { int i, m=15, y=-1;

for(i=2; i<=m/2; i++) if(m % i= =0) {y=0; break;} printf(“%d”,y); }

程序3

#include void main() { int i, m=15, y=-1;

for(i=2; i<=m/2; i++) if(m % i= =0) break; if(i> m/2) y=1; else y=0;

printf(“%d”,y); }

程序4

#include void main() {

共76页 第5页

int i, m=15, y=-1;

for(i=2; i<=m/2; i++) if(m % i= =0) { break; y=0; } printf(“%d”,y); }

(17) 程序1运行时,输出 (17) 。

A. 1 B. 0 C. 15 D. -15 (18) 程序1运行时,输出 (18) 。

A. 1 B. 0 C. 15 D. -15 (19) 程序1运行时,输出 (19) 。

A. 1 B. 0 C. 15 D. -15 (20) 程序1运行时,输出 (20) 。

A. 1 B. 0 C. 15 D. -15

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

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

#include void main() { int k; char ch, a[10], *s[10]={“one”, “two”, “three”, “four”}; k=0; while((ch=getchar())!=?\\n? && k<9) if(ch>?5? && ch

(21) 程序运行时,输入5678,输出 (21) 。

A. two three B. two C. one four three D. four three two one (22) 程序运行时,输入8561#,输出 (22) 。

A. two three B. two C. one four three D. four three two one (23) 程序运行时,输入7902#,输出 (23) 。

A. two three B. two C. one four three D. four three two one (24) 程序运行时,输入7633#,输出 (24) 。

A. two three B. two C. one four three D. four three two one

共76页 第6页

试题7(28分)

(1) 定义函数fact(n) 计算n的阶乘:n!=1*2*……*n,函数返回值类型是double。

(2) 定义函数cal(e) 计算下列算式的值,直到最后一项的绝对值小于e,函数返回值类型是

double。

111 s?1????......2!3!4!

(3) 定义函数main(),输入正整数n,当精度e分别取值为10-1、10-2、10-3/……10-n时,分别计

算并输出下列算式的值,直到最后一项绝对值小于精度e,以此比较不同精度下算出的结果。要求调用cal(e) 计算下列算式的值。

s?1?111???......2!3!4!共76页 第7页

2007年春浙江省高等学校 计算机等级考试试卷(二级C)

说明:⑴ 考生应将所有试题的答案填写在答卷上。其中试题一到试题六请在答卷上的各小题选项的

对应位置上填“√”。

⑵ 请将你的准考证号的后五位填写在答卷右下角的指定位置内; ⑶ 考试时间为90分钟。

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

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

输入一个正整数,按照从高位到低位的顺序输出各位数字。 运行示例:

Enter an integer: 1902 The digits are: 1 9 0 2

【程序】

#include void main( )

{ int digit, number, power, t; printf(\

scanf(\

number = number < 0 ? -number : number; power = 1; (1)

while( (2) ){ power *= 10; t /= 10; };

printf(\ while( (3) ){

digit = number / power; printf(\ (4) power /= 10; } }

【供选择的答案】

(1) A、 t = 1; B、t = number; C、 ; D、number = 1; (2) A、t >= 10

B、power >= 100

C、t != 0 D、number != 0 (3) A、 power == 0 B、digit != 0

C、number != 0 D、power >= 1 (4) A、number /= power; B、number %= 10;

共76页 第8页

联系合同范文客服:xxxxx#qq.com(#替换为@)