当前位置:首页 > 浙江省高等学校二级C语言(笔试部分真题2008-2010年)
void swap(int *x,int *y) { int t;
t=*x;*x=*y;*y=t; }
main() { int i,a[10];
printf(“Enter 10 integers:”); for(i=0;i<10;i++) scanf(“%d”,&a[i]); ___(12)___
printf(“After sorted:”); for(i=0;i<10;i++) printf(“%d ”,a[i]); printf(“\\n”); } 【供选择的答案】
(9) [A] void swap(int *x,int *y) [B] ;
[C] void swap(int *x,int *y); [D] void swap(int *x, *y) (10) [A] int &a,int n
[C] int *a,int n
(11) [A] swap(*a[index],*a[k])
[C] swap(index,k)
[B] int *a,int *n [D] int a,int *n
[B] swap(a[index],a[k]) [D] swap(&a[index],&a[k])
(12) [A] sort(a) [B] sort(a[10])
[C] sort(a[],10) [D] sort(a,10)
试题4(每小题3分,共12分)
阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序】 程序1
#include
{ int j,k,s1,s2; s1=s2=0;
for(j=1;j<=5;j++){ s1++;
for(k=1;k<=j;k++) s2++; }
printf(“%d %d”,s1,s2); }.
程序2
#include
{ int j,k,s1,s2; s1=0;
25
for(j=1;j<=5;j++){ s1++;
for(k=1,s2=0;k<=j;k++) s2++; }
printf(“%d %d”,s1,s2); }.
程序3
#include
{ int j,k,s1,s2; s1=0;
for(j=1;j<=5;j++){ s1++;
for(k=1;k<=j;k++,s2=0) s2++; }
printf(“%d %d”,s1,s2); }.
程序4
#include
{ int j,k,s1,s2; s1=s2=0;
for(j=1;j<=5;j++,s1=0){ s1++;
for(k=1;k<=j;k++) s2++; }
printf(“%d %d”,s1,s2); }.
【供选择的答案】
(13) 程序1运行时,输出:
[A] 0 15 [B]5 0 (14) 程序2运行时,输出: [A] 0 15 [B]5 0 (15) 程序3运行时,输出: [A] 0 15 [B]5 0 (16) 程序4运行时,输出: [A] 0 15 [B]5 0
[C]5 5 [C]5 5 [C]5 5 [C]5 5
[D] 5 15 [D] 5 15 [D] 5 15 [D] 5 15
试题5(每小题3分,共12分)
阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序】
程序1
#include
26
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
{ 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
{ 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
{ 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运行时,输出:
[A]1 [B]0 (18) 程序2运行时,输出: [A]15 [B]0 (19) 程序3运行时,输出: [A]-1 [B]1 (20) 程序4运行时,输出: [A]0 [B]15
[C]15 [C]-1 [C]0 [C]1
[D]-1 [D]1 [D]15 [D]-1
试题6(每小题3分,共12分)
阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序】
27
#include
char ch,a[10],*s[10]={“one”,”two”,”three”,”four”}; k=0;
while((ch=getchar())!=?\\n?&&k<9) if(ch>=?5?&&ch<=?8?) a[k++]=ch; a[k]=?\\0?;
for(k=0;a[k]!=?\\0?;k++) printf(“%ds”,s[(?9?-a[k])-1]); }
【供选择的答案】
(21) 程序运行时,输入5678,输出:
[A] two three [C] one four three (22) 程序运行时,输入8561#,输出:
[A] two three [C] one four three (23) 程序运行时,输入7902#,输出:
[A] two three [C] one four three (24) 程序运行时,输入7633#,输出:
[A] two three [C] one four three
[B] two
[D] four three two one [B] two
[D] four three two one [B] two
[D] four three two one [B] two
[D] four three two one
试题7(28分)
(1)定义函数fact(n)计算n的阶乘:n!=1*2*??*n,函数返回值类型是double。
(2)定义函数cal(e)计算下列算式的值,直到最后一项的绝对值小于e,函数返回值类型是double。 s=1+
(3)定义函数main(),输入正整数n,当精度e分别取值为10、10、10、??、10时,分别计算并输出下列算式的值,直到最后一项的绝对值小于精度e,以比较不同精度下算出的结果,要求调用函数cal(e)计算下列算式的值。
111???...... 2!3!4!-1-2-3-n
计算机等级考试参考答案(二级C)
试题1~6 (每小题3分)
⑴ A ⑵ A ⑶ B ⑷ B ⑸ A ⑹ B ⑺ C ⑻ D ⑼ C ⑽ C ⑾ D ⑿ D ⒀ D ⒁ C ⒂ B ⒃ A ⒄ A ⒅ B ⒆ C ⒇ D (21)D (22)C (23)B (24)A
28
共分享92篇相关文档