计算机等级考试浙江省和全国二级

  • 格式:doc
  • 大小:132.00 KB
  • 文档页数:13

2006年春浙江省高等学校计算机等级考试试卷(二级C)说明:⑴考生应将所有试题的答案填写在答卷上。

其中试题1~试题6,请在答卷上各小题正确选项的对应位置处填“√”;⑵请将你的准考证号的后五位填写在答卷右下角的指定位置内;⑶考试时间为90分钟;试题1(每小题3分,共12分)阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。

【程序说明】求 1 + 2/3 + 3/5 + 4/7 + 5/9 + …的前20项之和。

运行示例:sum = 11.239837【程序】#include <stdio.h>void main( ){int i, b = 1;double s;(1) ;for(i = 1; i <= 20; i++){s = s + (2) ;(3)}printf( (4) , s);}【供选择的答案】(1) A、s = 0 B、s = 1C、s = -1D、s = 2(2) A、i/b B、double(i)/double(b)C、i/2*i-1D、(double)i/(double)b(3) A、; B、b = 2 * i – 1;C、b = 1.0 * b;D、b = b + 2;(4) A、"sum = %d\n" B、"s = %c\n"C、"sum = %f\n"D、"s = %s\n"试题2(每小题3分,共12分)阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。

【程序说明】输入10个整数,将它们从大到小排序后输出。

运行示例:Enter 10 integers: 1 4 -9 99 100 87 0 6 5 34After sorted: 100 99 87 34 6 5 4 1 0 -9【程序】#include <stdio.h>void main( ){ int i, j, t, a[10];printf("Enter 10 integers: ");for(i = 0; i < 10; i++)scanf( (5) );for(i = 1; i < 10; i++)for( (6) ; (7) ; j++)if( (8) ){a[j] = a[j+1];a[j+1] = t;}printf("After sorted: ");for(i = 0; i < 10; i++)printf("%d ", a[i]);printf("\n");}【供选择的答案】(5) A、"%f", a[i] B、"%lf", &a[i]C、"%s", aD、"%d", &a[i](6) A、j = 0 B、j = 1C、j = iD、j = i - 1(7) A、j > i B、j < 9 - iC、j < 10 - iD、j > i - 1(8) A、a[i-1] < a[i] B、a[j+1] < a[j+2]C、a[j] < a[j+1]D、a[i] < a[j]试题3(每小题3分,共12分)阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。

【程序说明】输入一个字符串和一个正整数m,将该字符串中的前m个字符复制到另一个字符串中,再输出后一个字符串。

运行示例1:Enter a string: 103+895=?Enter an integer: 6The new string is 103+89运行示例2:Enter a string: 103+895=?Enter an integer: 60The new string is 103+895=?运行示例3:Enter a string: 103+895=?Enter an integer: 0The new string is【程序】#include <stdio.h>#include < (9) >void main( ){ char s[80], t[80], i, m;printf("Enter a string:");gets(s);printf("Enter an integer:");scanf("%d", &m);for(i = 0; (10) ; i++)(11) ;(12)puts(t);}【供选择的答案】(9) A、ctype.h B、math.hC、stdio.hD、string.h(10) A、i < m B、s[i]!= '\0'C、s[i]!= '\0' && i < mD、s[i]!= '\0' || i < m(11) A、*s++ = *t++ B、t[i] = s[i]C、*t++ = *s++D、s[i] = t[i](12) A、t[i] = '\0'; B、;C、*++s = '\0';D、*++t = '\0';试题4(每小题3分,共12分)阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。

【程序】#include <stdio.h>void main( ){ int s, x1, y1, z1, x2, y2, z2;printf("Enter 6 integers:");scanf("%d%d%d%d%d%d", &x1, &y1, &z1, &x2, &y2, &z2);s = f(x2, y2, z2) - f(x1, y1, z1);printf("%d\n", s);}f(int x, int y, int z){ int k, n;int tab[2][13] = {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} };n = (x % 4 == 0 && x % 100 != 0 || x % 400 == 0);for(k = 1; k < y; k++)z = z + tab[n][k];return z;}(13) 程序运行时,输入1 0 0 0 0 0,输出(13) 。

A、29B、28C、0D、-1(14) 程序运行时,输入0 0 1 0 0 0,输出(14) 。

A、29B、28C、0D、-1(15) 程序运行时,输入2000 2 1 2000 3 1,输出 (15) 。

A、29B、28C、0D、-1(16) 程序运行时,输入1981 2 1 1981 3 1,输出 (16) 。

A、29B、28C、0D、-1试题5(每小题3分,共12分)阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。

【程序】# include <stdio.h>void main ( ){ int a = -1, b = 1;void f1(int x, int y), f2(int *x, int *y);void f3(int *x, int *y), f4(int x, int y);f1(a, b);printf("(%d,%d)\n", a, b);a = -1,b = 1;f2(&a, &b);printf("(%d,%d)\n", a, b);a = -1,b = 1;f3(&a, &b);printf("(%d,%d)\n", a, b);a = -1,b = 1;f4(a, b);printf("(%d,%d)\n", a, b);}void f1(int x, int y){ int t;t = x; x = y; y = t;}void f2(int *x, int *y){ int t;t = *x; *x = *y; *y = t;}void f3(int *x, int *y){ int *t;t = x; x = y; y = t;}void f4(int x, int y){ int *t = malloc(sizeof(t));*t = x; x = y; y = *t;}(17) 程序运行时,第1行输出(17) 。

A、(1, -1)B、(-1, 1)C、(-1, -1)D、(1,1)(18) 程序运行时,第2行输出(18) 。

A、(1, -1)B、(-1, 1)C、(-1, -1)D、(1,1)(19) 程序运行时,第3行输出(19) 。

A、(1, -1)B、(-1, 1)C、(-1, -1)D、(1,1)(20) 程序运行时,第4行输出(20) 。

A、(1, -1)B、(-1, 1)C、(-1, -1)D、(1,1)试题6(每小题3分,共12分)#include <stdio.h>struct card{char *face;char *suit;};void filldeck(struct card *wdeck, char *wface[],char *wsuit[]) { int i;for (i = 0; i < 4; i++){wdeck[i].face = wface[i%2];wdeck[i].suit = wsuit[i/2];}}void deal(struct card *wdeck){ int i;for (i = 0; i < 4; i++)printf("(%2s of %-6s)\n", wdeck[i].face, wdeck[i].suit);}void main(){ struct card deck[4];char *face[]={"K","Q"};char *suit[]={"Heart","Club"};filldeck(deck,face,suit);deal(deck);}(21) 程序运行时,第1行输出 (21) 。